freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
June 2009
- 21 participants
- 537 discussions
[Freeswitch-svn] [commit] r14044 - in freeswitch/trunk/contrib/mod/endpoints/mod_khomp: . commons include src
by FreeSWITCH SVN 30 Jun '09
by FreeSWITCH SVN 30 Jun '09
30 Jun '09
Author: raulfragoso
Date: Tue Jun 30 02:38:50 2009
New Revision: 14044
Log:
Implemented some helper functions to start/stop the board mixer and audio callbacks;
The channel states are now working as they should !
Modified:
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/commons/k3lapi.cpp
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/src/khomp_pvt.cpp
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/commons/k3lapi.cpp
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/commons/k3lapi.cpp (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/commons/k3lapi.cpp Tue Jun 30 02:38:50 2009
@@ -40,24 +40,24 @@
void K3LAPI::mixer(int32 dev, int32 obj, byte track, KMixerSource src, int32 index)
{
- KMixerCommand mix;
+ KMixerCommand mix;
mix.Track = track;
- mix.Source = src;
+ mix.Source = src;
mix.SourceIndex = index;
- command(dev, obj, CM_MIXER, (const char *) &mix);
+ command(dev, obj, CM_MIXER, (const char *) &mix);
}
void K3LAPI::mixerCTbus(int32 dev, int32 obj, byte track, KMixerSource src, int32 index)
{
- KMixerCommand mix;
+ KMixerCommand mix;
mix.Track = track;
- mix.Source = src;
+ mix.Source = src;
mix.SourceIndex = index;
- command(dev, obj, CM_MIXER_CTBUS, (const char *) &mix);
+ command(dev, obj, CM_MIXER_CTBUS, (const char *) &mix);
}
void K3LAPI::command(int32 dev, int32 obj, int32 code, std::string & str)
@@ -69,12 +69,12 @@
{
K3L_COMMAND cmd;
- cmd.Cmd = code;
+ cmd.Cmd = code;
cmd.Object = obj;
- cmd.Params = (byte *)parms;
+ cmd.Params = (byte *)parms;
int32 rc = k3lSendCommand(dev, &cmd);
-
+
if (rc != ksSuccess)
throw failed_command(code, dev, obj, rc);
}
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h Tue Jun 30 02:38:50 2009
@@ -3,6 +3,8 @@
#include "globals.h"
+#define KHOMP_PACKET_SIZE 16
+
/*!
\brief This struct holds a static linked list representing all the Khomp channels
found in the host. It's also a place holder for session objects and some
@@ -14,15 +16,37 @@
typedef std::vector < KhompPvt * > PvtVectorType; /*!< Collection of pointers of KhompPvts */
typedef std::vector < PvtVectorType > PvtVector2Type; /*!< Collection of PvtVectorType */
typedef PvtVector2Type KhompPvtVector; /*!< A bidimensional array o KhompPvts, meaning [board][channel] */
-
+
+ K3LAPI::target _target; /*!< The card/device pair to bind this pvt to */
+ switch_core_session_t * _session; /*!< The session to which this pvt is associated with */
+
+ unsigned int flags; //TODO: Alterar o nome depois
+
+ switch_codec_t _read_codec;
+ switch_codec_t _write_codec;
+
+ switch_frame_t _read_frame;
+
+ switch_buffer_t * _audio_buffer; /*!< Audio buffer used to write data in the khomp callback and read by FS callback */
+
+ unsigned char _databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+
+ switch_caller_profile_t *_caller_profile;
+
+ switch_mutex_t *_mutex;
+ switch_mutex_t *flag_mutex; //TODO: Alterar o nome depois
+
+ unsigned int _KDeviceId; /*!< Represent de board we are making the call from */
+ unsigned int _KChannelId; /*!< Represent the channel we are making the call from */
+
KhompPvt(K3LAPI::target & target)
- : _target(target), _session(NULL) {};
+ : _target(target), _session(NULL) {};
K3LAPI::target target()
{
return _target;
}
-
+
void session(switch_core_session_t * newSession)
{
_session = newSession;
@@ -33,6 +57,23 @@
return _session;
}
+ int32 get_audio_dsp();
+
+ bool obtain_both(void);
+ bool obtain_rx(bool with_delay);
+ bool obtain_tx(void);
+
+ bool start_stream(void);
+ bool stop_stream(void);
+
+ bool start_listen(bool conn_rx = true);
+ bool stop_listen(void);
+
+ /* static stuff */
+ static switch_mutex_t *_pvts_mutex;
+
+ static KhompPvtVector _pvts; /*!< Static structure that contains all the pvts. Will be initialized by KhompPvt::initialize */
+
static KhompPvt * khompPvt(int32 device, int32 object)
{
if (!Globals::_k3lapi.valid_channel(device, object))
@@ -90,33 +131,7 @@
}
}
}
-
- K3LAPI::target _target;
- switch_core_session_t * _session; /*!< The session to which this pvt is associated with */
-
- unsigned int flags; //TODO: Alterar o nome depois
-
- switch_codec_t _read_codec;
- switch_codec_t _write_codec;
-
- switch_frame_t _read_frame;
-
- switch_buffer_t * _audio_buffer;
- unsigned char _databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
-
- switch_caller_profile_t *_caller_profile;
-
- switch_mutex_t *_mutex;
- switch_mutex_t *flag_mutex; //TODO: Alterar o nome depois
-
- unsigned int _KDeviceId; /*!< Represent de board we are making the call from */
- unsigned int _KChannelId; /*!< Represent the channel we are making the call from */
-
- /* static stuff */
- static switch_mutex_t *_pvts_mutex;
-
- static KhompPvtVector _pvts; /*!< Static structure that contains all the pvts. Will be initialized by KhompPvt::initialize */
};
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp Tue Jun 30 02:38:50 2009
@@ -993,8 +993,12 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not hangup channel: %u on board %u. Releasing board channel anyway. [EV_DISCONNECT]\n", obj, e->DeviceId);
try
{
- //Globals::_k3lapi.command(e->DeviceId, obj, CM_STOP_LISTEN, NULL);
+ /* Stop the audio callbacks */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stopping audio callbacks ...\n");
+ KhompPvt::khompPvt(e->DeviceId, obj)->stop_listen();
+ KhompPvt::khompPvt(e->DeviceId, obj)->stop_stream();
KhompPvt::khompPvt(e->DeviceId, obj)->session(NULL);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio callbacks stopped successfully\n");
}
catch(K3LAPI::invalid_channel & err)
{
@@ -1012,10 +1016,10 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Call will be answered on board %u, channel %u. [EV_CONNECT]\n", e->DeviceId, obj);
switch_channel_mark_answered(channel);
/* Start listening for audio */
- /*
- const size_t buffer_size = 16;
- Globals::_k3lapi.command(e->DeviceId, obj, CM_LISTEN, (const char *) &buffer_size);
- */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting audio callbacks ...\n");
+ KhompPvt::khompPvt(e->DeviceId, obj)->start_stream();
+ KhompPvt::khompPvt(e->DeviceId, obj)->start_listen();
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio callbacks initialized successfully\n");
}
catch (K3LAPI::invalid_session & err)
{
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/src/khomp_pvt.cpp
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/src/khomp_pvt.cpp (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/src/khomp_pvt.cpp Tue Jun 30 02:38:50 2009
@@ -153,3 +153,161 @@
switch_mutex_unlock(_pvts_mutex);
return pvt;
}
+
+/* Helper functions - based on code from chan_khomp */
+
+int32 KhompPvt::get_audio_dsp()
+{
+ switch (Globals::_k3lapi.device_type(_KDeviceId))
+ {
+ case kdtFXO:
+ case kdtFXOVoIP:
+ case kdtGSM:
+ case kdtGSMSpx:
+ return 0;
+ default:
+ return 1;
+ }
+}
+
+bool KhompPvt::obtain_both(void)
+{
+ /* estes buffers *NAO PODEM SER ESTATICOS*! */
+ char cmd1[] = { 0x3f, 0x03, 0xff, 0x00, 0x05, 0xff };
+ char cmd2[] = { 0x3f, 0x03, 0xff, 0x01, 0x00, 0xff };
+
+ cmd1[2] = cmd1[5] = cmd2[2] = cmd2[5] = _KChannelId;
+
+ int32 val = get_audio_dsp();
+
+ try
+ {
+ Globals::_k3lapi.raw_command(_KDeviceId, val, cmd1, 6);
+ Globals::_k3lapi.raw_command(_KDeviceId, val, cmd2, 6);
+ }
+ catch(...)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool KhompPvt::obtain_rx(bool with_delay)
+{
+ /* estes buffers *NAO PODEM SER ESTATICOS*! */
+ char cmd1[] = { 0x3f, 0x03, 0xff, 0x00, (with_delay ? 0x05 : 0x0a), 0xff };
+ char cmd2[] = { 0x3f, 0x03, 0xff, 0x01, 0x09, 0x0f };
+
+ cmd1[2] = cmd1[5] = cmd2[2] = _KChannelId;
+
+ int32 val = get_audio_dsp();
+
+ try
+ {
+ Globals::_k3lapi.raw_command(_KDeviceId, val, cmd1, 6);
+ Globals::_k3lapi.raw_command(_KDeviceId, val, cmd2, 6);
+ }
+ catch(...)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool KhompPvt::obtain_tx(void)
+{
+ /* estes buffers *NAO PODEM SER ESTATICOS*! */
+ char cmd1[] = { 0x3f, 0x03, 0xff, 0x00, 0x00, 0xff };
+ char cmd2[] = { 0x3f, 0x03, 0xff, 0x01, 0x09, 0x0f };
+
+ cmd1[2] = cmd1[5] = cmd2[2] = _KChannelId;
+
+ int32 val = get_audio_dsp();
+
+ try
+ {
+ Globals::_k3lapi.raw_command(_KDeviceId, val, cmd1, 6);
+ Globals::_k3lapi.raw_command(_KDeviceId, val, cmd2, 6);
+ }
+ catch(...)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool KhompPvt::start_stream(void)
+{
+ try
+ {
+ Globals::_k3lapi.mixer(_KDeviceId, _KChannelId, 0, kmsPlay, _KChannelId);
+ Globals::_k3lapi.command(_KDeviceId, _KChannelId, CM_START_STREAM_BUFFER);
+ //flags.set(kflags::STREAM_UP);
+ }
+ catch(...)
+ {
+ return false;
+ }
+ return true;
+}
+
+bool KhompPvt::stop_stream(void)
+{
+ try
+ {
+ Globals::_k3lapi.mixer(_KDeviceId, _KChannelId, 0, kmsGenerator, kmtSilence);
+ Globals::_k3lapi.command(_KDeviceId, _KChannelId, CM_STOP_STREAM_BUFFER);
+ //flags.clear(kflags::STREAM_UP);
+ }
+ catch(...)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool KhompPvt::start_listen(bool conn_rx)
+{
+ const size_t buffer_size = KHOMP_PACKET_SIZE;
+
+ if (conn_rx)
+ {
+ if (!obtain_rx(false)) // no delay, by default..
+ return false;
+ }
+
+ try
+ {
+ Globals::_k3lapi.command(_KDeviceId, _KChannelId, CM_LISTEN, (const char *) &buffer_size);
+ }
+ catch(...)
+ {
+ return false;
+ }
+
+ /* always set this flag to avoid constant 'ksInvalidState' messages. */
+ //flags.set(kflags::LISTEN_UP);
+
+ return true;
+}
+
+bool KhompPvt::stop_listen(void)
+{
+ try
+ {
+ Globals::_k3lapi.command(_KDeviceId, _KChannelId, CM_STOP_LISTEN);
+ }
+ catch(...)
+ {
+ return false;
+ }
+
+ //flags.clear(kflags::LISTEN_UP);
+
+ return true;
+}
+
1
0
[Freeswitch-svn] [commit] r14043 - in freeswitch/trunk/contrib/mod/endpoints/mod_khomp: . include
by FreeSWITCH SVN 30 Jun '09
by FreeSWITCH SVN 30 Jun '09
30 Jun '09
Author: raulfragoso
Date: Mon Jun 29 21:12:56 2009
New Revision: 14043
Log:
KhompPvt lacked some proper cleanup during shutdown
Modified:
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h Mon Jun 29 21:12:56 2009
@@ -79,7 +79,16 @@
static void terminate()
{
+ switch_mutex_lock(_pvts_mutex);
+ for(KhompPvtVector::iterator it_board = _pvts.begin(); it_board != _pvts.end(); it_board++)
+ {
+ for(PvtVectorType::iterator it_channel = it_board->begin(); it_channel != it_board->begin(); it_channel++)
+ {
+ KhompPvt * pvt = *it_channel;
+ delete pvt;
+ }
+ }
}
K3LAPI::target _target;
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp Mon Jun 29 21:12:56 2009
@@ -561,6 +561,7 @@
/* Finnish him! */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stopping K3L...\n");
+ KhompPvt::terminate();
Globals::_k3lapi.stop();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "the K3L API has been stopped!\n");
1
0
[Freeswitch-svn] [commit] r14042 - in freeswitch/trunk/src/mod/applications: mod_commands mod_expr
by FreeSWITCH SVN 30 Jun '09
by FreeSWITCH SVN 30 Jun '09
30 Jun '09
Author: brian
Date: Mon Jun 29 21:12:35 2009
New Revision: 14042
Log:
corrections thanks diego
Modified:
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/applications/mod_expr/mod_expr.c
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Mon Jun 29 21:12:35 2009
@@ -3532,7 +3532,7 @@
SWITCH_ADD_API(commands_api_interface, "domain_exists", "check if a domain exists", domain_exists_function, "<domain>");
SWITCH_ADD_API(commands_api_interface, "uuid_send_dtmf", "send dtmf digits", uuid_send_dtmf_function, UUID_SEND_DTMF_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "eval", "eval (noop)", eval_function, "[uuid:<uuid> ]<expression>");
- SWITCH_ADD_API(commands_api_interface, "expand", "expand vars and exexute", expand_function, "[uuid:<uuid> ]<cmd> <args>");
+ SWITCH_ADD_API(commands_api_interface, "expand", "expand vars and execute", expand_function, "[uuid:<uuid> ]<cmd> <args>");
SWITCH_ADD_API(commands_api_interface, "echo", "echo", echo_function, "<data>");
SWITCH_ADD_API(commands_api_interface, "stun", "stun", stun_function, "<stun_server>[:port]");
SWITCH_ADD_API(commands_api_interface, "system", "Execute a system command", system_function, SYSTEM_SYNTAX);
Modified: freeswitch/trunk/src/mod/applications/mod_expr/mod_expr.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/mod_expr.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/mod_expr.c Mon Jun 29 21:12:35 2009
@@ -195,7 +195,7 @@
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_API(commands_api_interface, "expr", "Eval an expession", expr_function, "<expr>");
+ SWITCH_ADD_API(commands_api_interface, "expr", "Eval an expression", expr_function, "<expr>");
/* indicate that the module should continue to be loaded */
1
0
[Freeswitch-svn] [commit] r14041 - freeswitch/trunk/contrib/jwehle/gs_phonebook
by FreeSWITCH SVN 30 Jun '09
by FreeSWITCH SVN 30 Jun '09
30 Jun '09
Author: jwehle
Date: Mon Jun 29 19:52:45 2009
New Revision: 14041
Log:
Initial commit
Added:
freeswitch/trunk/contrib/jwehle/gs_phonebook/
freeswitch/trunk/contrib/jwehle/gs_phonebook/README
freeswitch/trunk/contrib/jwehle/gs_phonebook/gs_phonebook.lua
Added: freeswitch/trunk/contrib/jwehle/gs_phonebook/README
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/jwehle/gs_phonebook/README Mon Jun 29 19:52:45 2009
@@ -0,0 +1,31 @@
+This directory contains software for outputting a phonebook
+suitable for download to a Grandstream phone. It is generated
+at startup and updated whenever a reloadxml occurs.
+
+gs_phonebook.lua goes into the FreeSWITCH scripts directory.
+
+Configuration fragments look something like:
+
+ conf/autoload_configs/lua.conf.xml
+
+ <param name="startup-script" value="gs_phonebook.lua"/>
+
+ Grandstream
+
+ Phonebook XML Download: YES, TFTP
+ Phonebook XML Server Path: <IP address of freeswitch server>
+ Phonebook Download Interval: <desired interval ... e.g. 240>
+
+and assumes that a tftp server has been configured. Obviously
+other arrangements can be used (e.g. http).
+
+The script uses LuaXml which is available from:
+
+ http://www.viremo.de/LuaXML/
+
+typical installation has:
+
+ /usr/local/lib/lua/5.1/LuaXML_lib.so
+ /usr/local/share/lua/5.1/LuaXml.lua
+
+Tested using FreeSWITCH SVN 13988 running on FreeBSD 6.4.
Added: freeswitch/trunk/contrib/jwehle/gs_phonebook/gs_phonebook.lua
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/jwehle/gs_phonebook/gs_phonebook.lua Mon Jun 29 19:52:45 2009
@@ -0,0 +1,132 @@
+--[[
+ * File: gs_phonebook.lua
+ * Purpose: Generate a downloadable phonebook for Grandstream phones.
+ * Machine: OS:
+ * Author: John Wehle Date: June 25, 2009
+ ]]--
+
+--[[
+ * Copyright (c) 2009 Feith Systems and Software, Inc.
+ * All Rights Reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ]]--
+
+
+require('LuaXml')
+
+
+-- RE to control which extensions are published
+local extRE = "^10[0-9][0-9]$"
+
+local gs_phonebook = "/tftpboot/gs_phonebook.xml"
+local maxEntries = 100
+
+
+function generate_phonebook ()
+
+ local api = freeswitch.API ()
+
+ local domain = api:execute ("global_getvar", "domain")
+
+ local dir = api:execute ("xml_locate", "directory domain name " .. domain)
+ local tdir = xml.eval (dir)
+
+ local tuser = xml.find (xml.find (xml.find (tdir,
+ "groups"), "group"), "users")
+
+ local i
+ local k1
+ local v1
+ local name
+ local fname
+ local lname
+ local number
+
+ local fd = io.open (gs_phonebook .. ".new", "w+")
+
+ io.output (fd)
+
+ io.write ("<?xml version=\"1.0\"?>\n<AddressBook>\n")
+
+ i = 0
+
+ for k1, v1 in pairs (tuser) do
+ if type (v1) == "table" and v1[xml.TAG] == "user" then
+ name = xml.find (v1, "variable", "name", "effective_caller_id_name")
+ number = xml.find (v1, "variable", "name", "effective_caller_id_number")
+ if name ~= nil and number ~= nil
+ and string.find (number["value"], extRE) ~= nil then
+
+ string.gsub (name["value"], "^[A-Za-z0-9]+",
+ function (w) fname = w end, 1)
+
+ string.gsub (name["value"], "[A-Za-z0-9]+$",
+ function (w) lname = w end, 1)
+
+ io.write (" <Contact>\n")
+ io.write (string.format (" <LastName>%s</LastName>\n", lname))
+ io.write (string.format (" <FirstName>%s</FirstName>\n", fname))
+ io.write (" <Phone>\n")
+ io.write (string.format (" <phonenumber>%s</phonenumber>\n",
+ number["value"]))
+ io.write (" <accountindex>0</accountindex>\n")
+ io.write (" </Phone>\n")
+ io.write (" </Contact>\n")
+
+ i = i + 1
+
+ if i >= maxEntries then
+ break
+ end
+ end
+ end
+ end
+
+ io.write ("</AddressBook>\n")
+
+ io.close (fd)
+
+ os.execute ("/bin/chmod 444 " .. gs_phonebook .. ".new")
+
+ os.rename (gs_phonebook .. ".new", gs_phonebook)
+end
+
+
+-- Refresh the phonebook on startup
+generate_phonebook ()
+
+-- and whenever the configuration changes
+local con = freeswitch.EventConsumer ("reloadxml")
+
+while con:pop(1) do
+ generate_phonebook ()
+end
+
+return
1
0
[Freeswitch-svn] [commit] r14040 - freeswitch/trunk/src/mod/applications/mod_commands
by FreeSWITCH SVN 30 Jun '09
by FreeSWITCH SVN 30 Jun '09
30 Jun '09
Author: mcollins
Date: Mon Jun 29 19:20:57 2009
New Revision: 14040
Log:
Add show syntax for distinct_channels
Modified:
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Mon Jun 29 19:20:57 2009
@@ -2700,7 +2700,7 @@
return SWITCH_STATUS_SUCCESS;
}
-#define SHOW_SYNTAX "codec|endpoint|application|api|dialplan|file|timer|calls [count]|channels [count]|aliases|complete|chat|endpoint|management|modules|say|interfaces|interface_types"
+#define SHOW_SYNTAX "codec|endpoint|application|api|dialplan|file|timer|calls [count]|channels [count]|distinct_channels|aliases|complete|chat|endpoint|management|modules|say|interfaces|interface_types"
SWITCH_STANDARD_API(show_function)
{
char sql[1024];
1
0
Author: mcollins
Date: Mon Jun 29 19:06:55 2009
New Revision: 14039
Log:
Update ChangeLog through r14038
Modified:
freeswitch/trunk/docs/ChangeLog
Modified: freeswitch/trunk/docs/ChangeLog
==============================================================================
--- freeswitch/trunk/docs/ChangeLog (original)
+++ freeswitch/trunk/docs/ChangeLog Mon Jun 29 19:06:55 2009
@@ -73,6 +73,8 @@
build: trivial build fix (FSBUILD-174/r:13877)
build: fix automake warnings about underquoted definitions in apr macros (FSBUILD-175/r:13882)
build: make libtool version detection more portable (r:13926)
+ build: change ODBC handling in code to be runtime instead of build time (r:13936)
+ build: update of spec file for current trunk (FSBUILD-176/r:13988)
config: default config, calling own extension no longer goes to voicemail (r:12596)
config: default config, 1000-1019 uses $${default_password} instead of hard-coded 1234 (FSCONFIG-5/r:12838)
config: tweak the configs to bind siptrace on and off to F10 and F11 (r:12938)
@@ -92,6 +94,7 @@
config: commit config options for new auto nat (r:13595)
config: Remove use_profile from default dialplan, move to vars.xml, default value is 'internal'
config: clean up configs and put wan.auto in by default commented out (r:13907)
+ config: turn on rollover by default (r:13940)
core: fix suncc visibility support in libteletone (r:12154-12157)
core: fix crash on FS shutdown with "..." (FSCORE-297/r:12173,12361,12402)
core: add separate mutex for state related methods (r:12191)
@@ -223,6 +226,8 @@
core: set sound path in say app (r:13904)
core: add wan.auto acl (r:13905)
core: Fix ACL nat.auto (FSCORE-385/r:13925)
+ core: add hostname variable (FSCORE-374/r:13982)
+ core: decrement RWLOCK->rwlock->__data->__nr_readers after Redirect/Transfer (FSCORE-391/r:14030)
docs: Fix filename references in phrase_en.xml (r:12976)
docs: Update phrase_en.xml to include v1.0.8 sound prompts (r:13041)
docs: Updates to phrase_es.xml (r:13067)
@@ -267,6 +272,8 @@
libesl: add Ruby example for ESL (ESL-15/r:13235)
libesl: add INFO example for Perl (r:13293)
libesl: add socketDescriptor() method to ESL::Connection obj (r:13770)
+ libesl: add prelims for Java ESL (r:13949,13950)
+ libesl: add fs_cli command line editing (FSCORE-389/r:13964)
libiksemel: let return 0 be a failure on read in iks to avoid cpu race (r:13123,13124,13133)
libnatpmp: add (r:13510)
libnspr: fix bsd port packaging (r:13715/FSBUILD-170)
@@ -293,6 +300,7 @@
libtiff: add libtiff, v3.8.2
libxmlrpc: add select to read socket in abyss so we can timeout (r:13107)
libxmlrpc: fix segfault (MODAPP-293/r:13906)
+ mod_cdr_csv: add option to disable creation of multiple files if account code is set (MODEVENT-44/r:13968)
mod_cidlookup: add new module, mod_cidlookup (r:12990)
mod_cidlookup: switch to using CURL instead of mod_http (r:12992)
mod_cidlookup: add config file (r:12994)
@@ -308,6 +316,7 @@
mod_commands: Add max-sessions to status (MODAPP-254/r:13373)
mod_commands: remove double safe_free's (r:13453,13454,13455)
mod_commands: add nat_map API (r:13531)
+ mod_commands: add show distinct_channels (mix of show channels and show calls) (r:13944)
mod_conference: fix read terminating on single digit when called from a meta-app inside a conference (MODAPP-226/r:12466)
mod_conference: recording members should be invisible to commands (MODAPP-233/r:12582)
mod_conference: add lock caller_control (r:12787)
@@ -402,6 +411,7 @@
mod_lua: fix visibility support (FSCORE-302/r:12239-12240)
mod_lua: fix windows build (FSBUILD-149/r:12919)
mod_lua: fix memory leak (MODLANG-111/r:13298)
+ mod_lua: fix error checking to be more reasonable (MODLANG-116/r:13993)
mod_managed: fix recursive file record during file playback issue (r:13551/IRC-00)
mod_memcache: add new module, mod_memcache; API for memcached (r:12871)
mod_memcache: make -ERR for API call less verbose (r:12949)
@@ -532,6 +542,10 @@
mod_sofia: fix segfault on refer with no content-type or body (SFSIP-153/r:13889)
mod_sofia: fix segfault on reinvite on nomedia call when using uuid_media (r:13894)
mod_sofia: use the register proxy for the R-URI on register when register-proxy is set (MODSOFIA-12/r:13911)
+ mod_sofia: Dereferencing a null pointer causes segfault: sofia_handle_sip_r_invite doesn't check profile->extsipip before use (FSCORE-386/r:13937)
+ mod_sofia: preserve transport on route (SFSIP-157/r:13948)
+ mod_sofia: do not set route_uri unless there is actually one to go to (r:13952)
+ mod_sofia: P-Asserted-Identity and P-Preferred-Identity headers now available as channel vars (BOUNTY-7 and MODENDP-146/r:13977)
mod_spidermonkey: fix segfaults on dtmf callback (FSCORE-327/r:12577)
mod_spidermonkey: fix error loading mod_spidermonkey due to missing PR_* symbols (r:12934,12939)
mod_spidermonkey: add destroy method to js (r:13016)
1
0
29 Jun '09
Author: crienzo
Date: Mon Jun 29 18:48:39 2009
New Revision: 14038
Log:
Loquendo MRCP Server 7 configuration
Added:
freeswitch/trunk/conf/mrcp_profiles/loquendo-7-mrcp-v2.xml
Added: freeswitch/trunk/conf/mrcp_profiles/loquendo-7-mrcp-v2.xml
==============================================================================
--- (empty file)
+++ freeswitch/trunk/conf/mrcp_profiles/loquendo-7-mrcp-v2.xml Mon Jun 29 18:48:39 2009
@@ -0,0 +1,23 @@
+<include>
+ <!-- Loquendo MRCP Server 7 MRCPv2 -->
+ <profile name="loquendo7-mrcp2" version="2">
+ <!--param name="client-ext-ip" value="auto"-->
+ <param name="client-ip" value="auto"/>
+ <param name="client-port" value="5090"/>
+ <param name="server-ip" value="10.5.5.152"/>
+ <param name="server-port" value="5060"/>
+ <!--param name="force-destination" value="1"/-->
+ <param name="sip-transport" value="udp"/>
+ <!--param name="ua-name" value="FreeSWITCH"/-->
+ <!--param name="sdp-origin" value="FreeSWITCH"/-->
+ <!--param name="rtp-ext-ip" value="auto"/-->
+ <param name="rtp-ip" value="auto"/>
+ <param name="rtp-port-min" value="4000"/>
+ <param name="rtp-port-max" value="5000"/>
+ <!--param name="playout-delay" value="50"/-->
+ <!--param name="max-playout-delay" value="200"/-->
+ <!--param name="ptime" value="20"/-->
+ <param name="codecs" value="PCMU PCMA L16/96/8000"/>
+ <param name="jsgf-mime-type" value="application/jsgf"/>
+ </profile>
+</include>
1
0
[Freeswitch-svn] [commit] r14037 - freeswitch/trunk/src/mod/asr_tts/mod_unimrcp
by FreeSWITCH SVN 29 Jun '09
by FreeSWITCH SVN 29 Jun '09
29 Jun '09
Author: crienzo
Date: Mon Jun 29 17:33:18 2009
New Revision: 14037
Log:
MODUNIMRCP-4
Modified:
freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
Modified: freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c (original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c Mon Jun 29 17:33:18 2009
@@ -53,6 +53,25 @@
#include "mrcp_client_connection.h"
#include "apt_net.h"
+
+/*********************************************************************************************************************************************
+ * PROFILE: profile management
+ */
+
+/**
+ * Profile-specific configuration. This allows us to handle differing MRCP server behavior
+ * on a per-profile basis
+ */
+struct profile {
+ char *name;
+ const char *jsgf_mime_type;
+ const char *gsl_mime_type;
+ const char *srgs_xml_mime_type;
+ const char *srgs_mime_type;
+};
+typedef struct profile profile_t;
+static switch_status_t profile_create(profile_t **profile, const char *name, switch_memory_pool_t *pool);
+
/*********************************************************************************************************************************************
* mod_unimrcp : module interface to FreeSWITCH
*/
@@ -62,6 +81,7 @@
/* module config file */
#define CONFIG_FILE "unimrcp.conf"
+
/**
* A UniMRCP application.
*/
@@ -105,6 +125,8 @@
switch_mutex_t *mutex;
/** next available speech channel number */
int speech_channel_number;
+ /** the available profiles */
+ switch_hash_t *profiles;
};
typedef struct mod_unimrcp_globals mod_unimrcp_globals_t;
@@ -131,10 +153,11 @@
SWITCH_MODULE_DEFINITION(mod_unimrcp, mod_unimrcp_load, mod_unimrcp_shutdown, NULL);
static switch_status_t mod_unimrcp_do_config();
-static mrcp_client_t *mod_unimrcp_client_create();
+static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool);
static int process_rtp_config(mrcp_client_t *client, mpf_rtp_config_t *rtp_config, const char *param, const char *val, apr_pool_t *pool);
static int process_mrcpv1_config(rtsp_client_config_t *config, const char *param, const char *val, apr_pool_t *pool);
static int process_mrcpv2_config(mrcp_sofia_client_config_t *config, const char *param, const char *val, apr_pool_t *pool);
+static int process_profile_config(profile_t *profile, const char *param, const char *val, apr_pool_t *pool);
/* UniMRCP <--> FreeSWITCH logging bridge */
static apt_bool_t unimrcp_log(const char *file, int line, const char *id, apt_log_priority_e priority, const char *format, va_list arg_ptr);
@@ -162,6 +185,7 @@
typedef struct unimrcp_param_id unimrcp_param_id_t;
static unimrcp_param_id_t *unimrcp_param_id_create(int id, switch_memory_pool_t *pool);
+
/********************************************************************************************************************************************
* AUDIO QUEUE : UniMRCP <--> FreeSWITCH audio buffering
*/
@@ -248,6 +272,8 @@
struct speech_channel {
/** the name of this channel (for logging) */
char *name;
+ /** The profile used by this channel */
+ profile_t *profile;
/** type of channel */
speech_channel_type_t type;
/** application this channel is running */
@@ -286,7 +312,7 @@
/* speech_channel funcs */
static switch_status_t speech_channel_create(speech_channel_t **schannel, const char *name, speech_channel_type_t type, mod_unimrcp_application_t *app, const char *codec, uint16_t rate, switch_memory_pool_t *pool);
-static switch_status_t speech_channel_open(speech_channel_t *schannel, const char *profile_name);
+static switch_status_t speech_channel_open(speech_channel_t *schannel, profile_t *profile);
static switch_status_t speech_channel_destroy(speech_channel_t *schannel);
static switch_status_t speech_channel_stop(speech_channel_t *schannel);
static switch_status_t speech_channel_set_param(speech_channel_t *schannel, const char *name, const char *val);
@@ -364,7 +390,7 @@
typedef struct grammar grammar_t;
static switch_status_t grammar_create(grammar_t **grammar, const char *name, grammar_type_t type, const char *data, switch_memory_pool_t *pool);
-static const char *grammar_type_to_mime(grammar_type_t type);
+static const char *grammar_type_to_mime(grammar_type_t type, profile_t *profile);
/*********************************************************************************************************************************************
* RECOGNIZER : UniMRCP <--> FreeSWITCH asr interface
@@ -421,6 +447,35 @@
static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int id, char *val, mrcp_message_t *msg, mrcp_recog_header_t *recog_hdr);
static switch_status_t recog_channel_set_timers_started(speech_channel_t *schannel);
+
+/**
+ * Create a mod_unimrcp profile
+ * @param profile the created profile
+ * @param name the profile name
+ * @param pool the memory pool to use
+ * @return SWITCH_STATUS_SUCCESS
+ */
+static switch_status_t profile_create(profile_t **profile, const char *name, switch_memory_pool_t *pool)
+{
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ profile_t *lprofile = NULL;
+
+ lprofile = (profile_t *)switch_core_alloc(pool, sizeof(profile_t));
+ if (lprofile) {
+ lprofile->name = switch_core_strdup(pool, name);
+ lprofile->srgs_mime_type = "application/srgs";
+ lprofile->srgs_xml_mime_type = "application/srgs+xml";
+ lprofile->gsl_mime_type = "application/x-nuance-gsl";
+ lprofile->jsgf_mime_type = "application/x-jsgf";
+ *profile = lprofile;
+ } else {
+ *profile = NULL;
+ status = SWITCH_STATUS_FALSE;
+ }
+
+ return status;
+}
+
/**
* Inspect text to determine if its first non-whitespace text matches "match"
* @param text the text to inspect.
@@ -694,7 +749,7 @@
status = SWITCH_STATUS_FALSE;
goto done;
}
-
+ schan->profile = NULL;
schan->type = type;
schan->application = app;
schan->state = SPEECH_CHANNEL_CLOSED;
@@ -702,7 +757,7 @@
schan->params = NULL;
schan->rate = rate;
schan->codec = switch_core_strdup(pool, codec);
-
+
if (!strcmp("L16", schan->codec)) {
schan->silence = 0;
} else {
@@ -759,10 +814,10 @@
* Open the speech channel
*
* @param schannel the channel to open
- * @param profile_name the profile to use
+ * @param profile the profile to use
* @return SWITCH_STATUS_FALSE if failed, SWITCH_STATUS_RESTART if retry can be attempted with another profile, SWITCH_STATUS_SUCCESS if successful
*/
-static switch_status_t speech_channel_open(speech_channel_t *schannel, const char *profile_name)
+static switch_status_t speech_channel_open(speech_channel_t *schannel, profile_t *profile)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
mpf_termination_t *termination = NULL;
@@ -770,17 +825,19 @@
mrcp_resource_type_e resource_type;
switch_mutex_lock(schannel->mutex);
-
+
/* make sure we can open channel */
if (schannel->state != SPEECH_CHANNEL_CLOSED) {
status = SWITCH_STATUS_FALSE;
goto done;
}
+ schannel->profile = profile;
+
/* create MRCP session */
- if ((schannel->unimrcp_session = mrcp_application_session_create(schannel->application->app, profile_name, schannel)) == NULL) {
+ if ((schannel->unimrcp_session = mrcp_application_session_create(schannel->application->app, profile->name, schannel)) == NULL) {
/* profile doesn't exist? */
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create session with %s\n", schannel->name, profile_name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create session with %s\n", schannel->name, profile->name);
status = SWITCH_STATUS_RESTART;
goto done;
}
@@ -810,7 +867,7 @@
termination = mrcp_application_source_termination_create(schannel->unimrcp_session, &schannel->application->audio_stream_vtable, codec, schannel);
}
if(termination == NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create termination with %s\n", schannel->name, profile_name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create termination with %s\n", schannel->name, profile->name);
mrcp_application_session_destroy(schannel->unimrcp_session);
status = SWITCH_STATUS_FALSE;
goto done;
@@ -821,7 +878,7 @@
resource_type = MRCP_RECOGNIZER_RESOURCE;
}
if ((schannel->unimrcp_channel = mrcp_application_channel_create(schannel->unimrcp_session, resource_type, termination, NULL, schannel)) == NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create channel with %s\n", schannel->name, profile_name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create channel with %s\n", schannel->name, profile->name);
mrcp_application_session_destroy(schannel->unimrcp_session);
status = SWITCH_STATUS_FALSE;
goto done;
@@ -829,7 +886,7 @@
/* add channel to session... this establishes the connection to the MRCP server */
if (mrcp_application_channel_add(schannel->unimrcp_session, schannel->unimrcp_channel) != TRUE) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to add channel to session with %s\n", schannel->name, profile_name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to add channel to session with %s\n", schannel->name, profile->name);
mrcp_application_session_destroy(schannel->unimrcp_session);
status = SWITCH_STATUS_FALSE;
goto done;
@@ -1322,10 +1379,11 @@
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
speech_channel_t *schannel = NULL;
- const char *profile = sh->param;
+ const char *profile_name = sh->param;
+ profile_t *profile = NULL;
int speech_channel_number = get_next_speech_channel_number();
char name[200] = { 0 };
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "speech_handle: name = %s, rate = %d, speed = %d, samples = %d, voice = %s, engine = %s, param = %s\n",
sh->name, sh->rate, sh->speed, sh->samples, sh->voice, sh->engine, sh->param);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "voice = %s, rate = %d\n", voice_name, rate);
@@ -1343,8 +1401,14 @@
sh->private_info = schannel;
/* try to open an MRCP channel */
- if (switch_strlen_zero(profile)) {
- profile = globals.unimrcp_default_synth_profile;
+ if (switch_strlen_zero(profile_name)) {
+ profile_name = globals.unimrcp_default_synth_profile;
+ }
+ profile = (profile_t *)switch_core_hash_find(globals.profiles, profile_name);
+ if (!profile) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Can't find profile, %s\n", name, profile_name);
+ status = SWITCH_STATUS_FALSE;
+ goto done;
}
if (speech_channel_open(schannel, profile) != SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_FALSE;
@@ -1765,17 +1829,18 @@
/**
* Get the MIME type for this grammar type
* @param type the grammar type
+ * @param profile the profile requesting the type
* @return the MIME type
*/
-static const char *grammar_type_to_mime(grammar_type_t type)
+static const char *grammar_type_to_mime(grammar_type_t type, profile_t *profile)
{
switch(type) {
case GRAMMAR_TYPE_UNKNOWN: return "";
case GRAMMAR_TYPE_URI: return "text/uri-list";
- case GRAMMAR_TYPE_SRGS: return "application/srgs";
- case GRAMMAR_TYPE_SRGS_XML: return "application/srgs+xml";
- case GRAMMAR_TYPE_NUANCE_GSL: return "application/x-nuance-gsl";
- case GRAMMAR_TYPE_JSGF: return "application/x-jsgf";
+ case GRAMMAR_TYPE_SRGS: return profile->srgs_mime_type;
+ case GRAMMAR_TYPE_SRGS_XML: return profile->srgs_xml_mime_type;
+ case GRAMMAR_TYPE_NUANCE_GSL: return profile->gsl_mime_type;
+ case GRAMMAR_TYPE_JSGF: return profile->jsgf_mime_type;
}
return "";
}
@@ -1829,7 +1894,7 @@
}
/* set Content-Type */
- mime_type = grammar_type_to_mime(r->grammar->type);
+ mime_type = grammar_type_to_mime(r->grammar->type, schannel->profile);
if (switch_strlen_zero(mime_type)) {
status = SWITCH_STATUS_FALSE;
goto done;
@@ -1923,7 +1988,7 @@
status = SWITCH_STATUS_FALSE;
goto done;
}
- mime_type = grammar_type_to_mime(type);
+ mime_type = grammar_type_to_mime(type, schannel->profile);
if (switch_strlen_zero(mime_type)) {
status = SWITCH_STATUS_FALSE;
goto done;
@@ -2404,7 +2469,8 @@
speech_channel_t *schannel = NULL;
int speech_channel_number = get_next_speech_channel_number();
char name[200] = { 0 };
- const char *profile;
+ const char *profile_name;
+ profile_t *profile = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "asr_handle: name = %s, codec = %s, rate = %d, grammar = %s, param = %s\n",
ah->name, ah->codec, ah->rate, ah->grammar, ah->param);
@@ -2424,7 +2490,13 @@
memset(schannel->data, 0, sizeof(recognizer_data_t));
/* try to open an MRCP channel */
- profile = switch_strlen_zero(dest) ? globals.unimrcp_default_recog_profile : dest;
+ profile_name = switch_strlen_zero(dest) ? globals.unimrcp_default_recog_profile : dest;
+ profile = (profile_t *)switch_core_hash_find(globals.profiles, profile_name);
+ if (!profile) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Can't find profile, %s\n", name, profile_name);
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
status = speech_channel_open(schannel, profile);
done:
@@ -2524,7 +2596,7 @@
goto done;
}
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar is %s\n", schannel->name, grammar_type_to_mime(type));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar is %s\n", schannel->name, grammar_type_to_mime(type, schannel->profile));
/* load the grammar and start recognition */
if (recog_channel_load_grammar(schannel, lname, type, grammar_data) != SWITCH_STATUS_SUCCESS) {
@@ -2996,6 +3068,32 @@
}
/**
+ * set mod_unimrcp-specific profile configuration
+ *
+ * @param profile the MRCP profile to configure
+ * @param param the param name
+ * @param val the param value
+ * @param pool the memory pool to use
+ */
+static int process_profile_config(profile_t *profile, const char *param, const char *val, switch_memory_pool_t *pool)
+{
+ int mine = 1;
+ if (strcasecmp(param, "jsgf-mime-type") == 0) {
+ profile->jsgf_mime_type = switch_core_strdup(pool, val);
+ } else if (strcasecmp(param, "gsl-mime-type") == 0) {
+ profile->gsl_mime_type = switch_core_strdup(pool, val);
+ } else if (strcasecmp(param, "srgs-xml-mime-type") == 0) {
+ profile->srgs_xml_mime_type = switch_core_strdup(pool, val);
+ } else if (strcasecmp(param, "srgs-mime-type") == 0) {
+ profile->srgs_mime_type = switch_core_strdup(pool, val);
+ } else {
+ mine = 0;
+ }
+
+ return mine;
+}
+
+/**
* set RTP config struct with param, val pair
* @param client the MRCP client
* @param rtp_config the config struct to set
@@ -3112,7 +3210,7 @@
*
* @return the MRCP client
*/
-static mrcp_client_t *mod_unimrcp_client_create()
+static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool)
{
switch_xml_t cfg = NULL, xml = NULL, profiles = NULL, profile = NULL;
mrcp_client_t *client = NULL;
@@ -3128,7 +3226,7 @@
client = mrcp_client_create(globals.unimrcp_dir_layout);
if (!client)
goto done;
-
+
pool = mrcp_client_memory_pool_get(client);
if (!pool)
goto done;
@@ -3177,6 +3275,7 @@
mpf_termination_factory_t *termination_factory = NULL;
mrcp_profile_t * mprofile = NULL;
mpf_rtp_config_t *rtp_config = NULL;
+ profile_t *mod_profile = NULL;
/* get profile attributes */
const char *name = apr_pstrdup(pool, switch_xml_attr(profile, "name"));
@@ -3187,6 +3286,10 @@
goto done;
}
+ /* prepare mod_unimrcp's profile for configuration */
+ profile_create(&mod_profile, name, mod_pool);
+ switch_core_hash_insert(globals.profiles, mod_profile->name, mod_profile);
+
/* create RTP config, common to MRCPv1 and MRCPv2 */
rtp_config = mpf_rtp_config_create(pool);
rtp_config->rtp_port_min = DEFAULT_RTP_PORT_MIN;
@@ -3211,7 +3314,8 @@
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading Param %s:%s\n", param_name, param_value);
if (!process_mrcpv1_config(config, param_name, param_value, pool) &&
- !process_rtp_config(client, rtp_config, param_name, param_value, pool)) {
+ !process_rtp_config(client, rtp_config, param_name, param_value, pool) &&
+ !process_profile_config(mod_profile, param_name, param_value, mod_pool)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown param %s\n", param_name);
}
}
@@ -3238,7 +3342,8 @@
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading Param %s:%s\n", param_name, param_value);
if (!process_mrcpv2_config(config, param_name, param_value, pool) &&
- !process_rtp_config(client, rtp_config, param_name, param_value, pool)) {
+ !process_rtp_config(client, rtp_config, param_name, param_value, pool) &&
+ !process_profile_config(mod_profile, param_name, param_value, mod_pool)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown param %s\n", param_name);
}
}
@@ -3283,9 +3388,9 @@
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
memset(&globals, 0, sizeof(globals));
-
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_UNNESTED, pool);
globals.speech_channel_number = 0;
+ switch_core_hash_init_case(&globals.profiles, pool, SWITCH_FALSE /* case_sensitive */);
/* get MRCP module configuration */
mod_unimrcp_do_config();
@@ -3310,7 +3415,7 @@
apt_log_ext_handler_set(unimrcp_log);
/* Create the MRCP client */
- if ((globals.mrcp_client = mod_unimrcp_client_create()) == NULL) {
+ if ((globals.mrcp_client = mod_unimrcp_client_create(pool)) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create mrcp client\n");
return SWITCH_STATUS_FALSE;
}
@@ -3347,6 +3452,7 @@
globals.mrcp_client = 0;
switch_mutex_destroy(globals.mutex);
+ switch_core_hash_destroy(&globals.profiles);
return SWITCH_STATUS_SUCCESS;
}
1
0
[Freeswitch-svn] [commit] r14036 - freeswitch/trunk/contrib/cparker/mod_xml_radius/conf
by FreeSWITCH SVN 29 Jun '09
by FreeSWITCH SVN 29 Jun '09
29 Jun '09
Author: cparker
Date: Mon Jun 29 16:03:02 2009
New Revision: 14036
Log:
Include dictionary
Added:
freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/dictionary
Added: freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/dictionary
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/dictionary Mon Jun 29 16:03:02 2009
@@ -0,0 +1,381 @@
+#
+# Updated 97/06/13 to livingston-radius-2.01 miquels(a)cistron.nl
+#
+# This file contains dictionary translations for parsing
+# requests and generating responses. All transactions are
+# composed of Attribute/Value Pairs. The value of each attribute
+# is specified as one of 4 data types. Valid data types are:
+#
+# string - 0-253 octets
+# ipaddr - 4 octets in network byte order
+# integer - 32 bit value in big endian order (high byte first)
+# date - 32 bit value in big endian order - seconds since
+# 00:00:00 GMT, Jan. 1, 1970
+#
+# Enumerated values are stored in the user file with dictionary
+# VALUE translations for easy administration.
+#
+# Example:
+#
+# ATTRIBUTE VALUE
+# --------------- -----
+# Framed-Protocol = PPP
+# 7 = 1 (integer encoding)
+#
+
+#
+# Following are the proper new names. Use these.
+#
+ATTRIBUTE User-Name 1 string
+ATTRIBUTE Password 2 string
+ATTRIBUTE CHAP-Password 3 string
+ATTRIBUTE NAS-IP-Address 4 ipaddr
+ATTRIBUTE NAS-Port-Id 5 integer
+ATTRIBUTE Service-Type 6 integer
+ATTRIBUTE Framed-Protocol 7 integer
+ATTRIBUTE Framed-IP-Address 8 ipaddr
+ATTRIBUTE Framed-IP-Netmask 9 ipaddr
+ATTRIBUTE Framed-Routing 10 integer
+ATTRIBUTE Filter-Id 11 string
+ATTRIBUTE Framed-MTU 12 integer
+ATTRIBUTE Framed-Compression 13 integer
+ATTRIBUTE Login-IP-Host 14 ipaddr
+ATTRIBUTE Login-Service 15 integer
+ATTRIBUTE Login-TCP-Port 16 integer
+ATTRIBUTE Reply-Message 18 string
+ATTRIBUTE Callback-Number 19 string
+ATTRIBUTE Callback-Id 20 string
+ATTRIBUTE Framed-Route 22 string
+ATTRIBUTE Framed-IPX-Network 23 ipaddr
+ATTRIBUTE State 24 string
+ATTRIBUTE Class 25 string
+ATTRIBUTE Vendor-Specific 26 string
+ATTRIBUTE Session-Timeout 27 integer
+ATTRIBUTE Idle-Timeout 28 integer
+ATTRIBUTE Termination-Action 29 integer
+ATTRIBUTE Called-Station-Id 30 string
+ATTRIBUTE Calling-Station-Id 31 string
+ATTRIBUTE NAS-Identifier 32 string
+ATTRIBUTE Proxy-State 33 string
+ATTRIBUTE Login-LAT-Service 34 string
+ATTRIBUTE Login-LAT-Node 35 string
+ATTRIBUTE Login-LAT-Group 36 string
+ATTRIBUTE Framed-AppleTalk-Link 37 integer
+ATTRIBUTE Framed-AppleTalk-Network 38 integer
+ATTRIBUTE Framed-AppleTalk-Zone 39 string
+ATTRIBUTE Acct-Status-Type 40 integer
+ATTRIBUTE Acct-Delay-Time 41 integer
+ATTRIBUTE Acct-Input-Octets 42 integer
+ATTRIBUTE Acct-Output-Octets 43 integer
+ATTRIBUTE Acct-Session-Id 44 string
+ATTRIBUTE Acct-Authentic 45 integer
+ATTRIBUTE Acct-Session-Time 46 integer
+ATTRIBUTE Acct-Input-Packets 47 integer
+ATTRIBUTE Acct-Output-Packets 48 integer
+ATTRIBUTE Acct-Terminate-Cause 49 integer
+ATTRIBUTE Acct-Multi-Session-Id 50 string
+ATTRIBUTE Acct-Link-Count 51 integer
+ATTRIBUTE Event-Timestamp 55 integer
+ATTRIBUTE CHAP-Challenge 60 string
+ATTRIBUTE NAS-Port-Type 61 integer
+ATTRIBUTE Port-Limit 62 integer
+ATTRIBUTE Login-LAT-Port 63 integer
+ATTRIBUTE Connect-Info 77 string
+
+#
+# RFC3162 IPv6 attributes
+#
+ATTRIBUTE NAS-IPv6-Address 95 string
+ATTRIBUTE Framed-Interface-Id 96 string
+ATTRIBUTE Framed-IPv6-Prefix 97 string
+ATTRIBUTE Login-IPv6-Host 98 string
+ATTRIBUTE Framed-IPv6-Route 99 string
+ATTRIBUTE Framed-IPv6-Pool 100 string
+
+ATTRIBUTE Digest-Response 206 string
+ATTRIBUTE Digest-Attributes 207 string # stupid format
+
+#define PW_DIGEST_REALM 1063 /* string */
+#define PW_DIGEST_NONCE 1064 /* string */
+#define PW_DIGEST_METHOD 1065 /* string */
+#define PW_DIGEST_URI 1066 /* string */
+#define PW_DIGEST_QOP 1067 /* string */
+#define PW_DIGEST_ALGORITHM 1068 /* string */
+#define PW_DIGEST_BODY_DIGEST 1069 /* string */
+#define PW_DIGEST_CNONCE 1070 /* string */
+#define PW_DIGEST_NONCE_COUNT 1071 /* string */
+#define PW_DIGEST_USER_NAME 1072 /* string */
+
+ATTRIBUTE Digest-Realm 1063 string
+ATTRIBUTE Digest-Nonce 1064 string
+ATTRIBUTE Digest-Method 1065 string
+ATTRIBUTE Digest-URI 1066 string
+ATTRIBUTE Digest-QOP 1067 string
+ATTRIBUTE Digest-Algorithm 1068 string
+ATTRIBUTE Digest-Body-Digest 1069 string
+ATTRIBUTE Digest-CNonce 1070 string
+ATTRIBUTE Digest-Nonce-Count 1071 string
+ATTRIBUTE Digest-User-Name 1072 string
+
+#
+# Experimental Non Protocol Attributes used by Cistron-Radiusd
+#
+ATTRIBUTE Huntgroup-Name 221 string
+ATTRIBUTE User-Category 1029 string
+ATTRIBUTE Group-Name 1030 string
+ATTRIBUTE Simultaneous-Use 1034 integer
+ATTRIBUTE Strip-User-Name 1035 integer
+ATTRIBUTE Fall-Through 1036 integer
+ATTRIBUTE Add-Port-To-IP-Address 1037 integer
+ATTRIBUTE Exec-Program 1038 string
+ATTRIBUTE Exec-Program-Wait 1039 string
+ATTRIBUTE Hint 1040 string
+
+#
+# Non-Protocol Attributes
+# These attributes are used internally by the server
+#
+ATTRIBUTE Expiration 21 date
+ATTRIBUTE Auth-Type 1000 integer
+ATTRIBUTE Menu 1001 string
+ATTRIBUTE Termination-Menu 1002 string
+ATTRIBUTE Prefix 1003 string
+ATTRIBUTE Suffix 1004 string
+ATTRIBUTE Group 1005 string
+ATTRIBUTE Crypt-Password 1006 string
+ATTRIBUTE Connect-Rate 1007 integer
+
+#
+# Integer Translations
+#
+
+# User Types
+
+VALUE Service-Type Login-User 1
+VALUE Service-Type Framed-User 2
+VALUE Service-Type Callback-Login-User 3
+VALUE Service-Type Callback-Framed-User 4
+VALUE Service-Type Outbound-User 5
+VALUE Service-Type Administrative-User 6
+VALUE Service-Type NAS-Prompt-User 7
+
+# Framed Protocols
+
+VALUE Framed-Protocol PPP 1
+VALUE Framed-Protocol SLIP 2
+
+# Framed Routing Values
+
+VALUE Framed-Routing None 0
+VALUE Framed-Routing Broadcast 1
+VALUE Framed-Routing Listen 2
+VALUE Framed-Routing Broadcast-Listen 3
+
+# Framed Compression Types
+
+VALUE Framed-Compression None 0
+VALUE Framed-Compression Van-Jacobson-TCP-IP 1
+
+# Login Services
+
+VALUE Login-Service Telnet 0
+VALUE Login-Service Rlogin 1
+VALUE Login-Service TCP-Clear 2
+VALUE Login-Service PortMaster 3
+
+# Status Types
+
+VALUE Acct-Status-Type Start 1
+VALUE Acct-Status-Type Stop 2
+VALUE Acct-Status-Type Alive 3
+VALUE Acct-Status-Type Accounting-On 7
+VALUE Acct-Status-Type Accounting-Off 8
+
+# Authentication Types
+
+VALUE Acct-Authentic RADIUS 1
+VALUE Acct-Authentic Local 2
+VALUE Acct-Authentic PowerLink128 100
+
+# Termination Options
+
+VALUE Termination-Action Default 0
+VALUE Termination-Action RADIUS-Request 1
+
+# NAS Port Types, available in 3.3.1 and later
+
+VALUE NAS-Port-Type Async 0
+VALUE NAS-Port-Type Sync 1
+VALUE NAS-Port-Type ISDN 2
+VALUE NAS-Port-Type ISDN-V120 3
+VALUE NAS-Port-Type ISDN-V110 4
+
+# Acct Terminate Causes, available in 3.3.2 and later
+
+VALUE Acct-Terminate-Cause User-Request 1
+VALUE Acct-Terminate-Cause Lost-Carrier 2
+VALUE Acct-Terminate-Cause Lost-Service 3
+VALUE Acct-Terminate-Cause Idle-Timeout 4
+VALUE Acct-Terminate-Cause Session-Timeout 5
+VALUE Acct-Terminate-Cause Admin-Reset 6
+VALUE Acct-Terminate-Cause Admin-Reboot 7
+VALUE Acct-Terminate-Cause Port-Error 8
+VALUE Acct-Terminate-Cause NAS-Error 9
+VALUE Acct-Terminate-Cause NAS-Request 10
+VALUE Acct-Terminate-Cause NAS-Reboot 11
+VALUE Acct-Terminate-Cause Port-Unneeded 12
+VALUE Acct-Terminate-Cause Port-Preempted 13
+VALUE Acct-Terminate-Cause Port-Suspended 14
+VALUE Acct-Terminate-Cause Service-Unavailable 15
+VALUE Acct-Terminate-Cause Callback 16
+VALUE Acct-Terminate-Cause User-Error 17
+VALUE Acct-Terminate-Cause Host-Request 18
+
+#
+# Non-Protocol Integer Translations
+#
+
+VALUE Auth-Type Local 0
+VALUE Auth-Type System 1
+VALUE Auth-Type SecurID 2
+VALUE Auth-Type Crypt-Local 3
+VALUE Auth-Type Reject 4
+
+#
+# Cistron extensions
+#
+VALUE Auth-Type Pam 253
+VALUE Auth-Type Accept 254
+
+#
+# Experimental Non-Protocol Integer Translations for Cistron-Radiusd
+#
+VALUE Fall-Through No 0
+VALUE Fall-Through Yes 1
+VALUE Add-Port-To-IP-Address No 0
+VALUE Add-Port-To-IP-Address Yes 1
+
+#
+# Configuration Values
+# uncomment these two lines to turn account expiration on
+#
+
+#VALUE Server-Config Password-Expiration 30
+#VALUE Server-Config Password-Warning 5
+
+# -*- text -*-
+#
+# dictionary.freeswitch
+#
+# cparker(a)segv.org
+#
+# Version: $Id: $
+#
+
+VENDOR Freeswitch 27880
+
+#
+# Standard attribute
+#
+BEGIN-VENDOR Freeswitch
+
+ATTRIBUTE Freeswitch-AVPair 1 string Freeswitch
+ATTRIBUTE Freeswitch-CLID 2 string Freeswitch
+ATTRIBUTE Freeswitch-Dialplan 3 string Freeswitch
+ATTRIBUTE Freeswitch-Src 4 string Freeswitch
+ATTRIBUTE Freeswitch-Dst 5 string Freeswitch
+ATTRIBUTE Freeswitch-Src-Channel 6 string Freeswitch
+ATTRIBUTE Freeswitch-Dst-Channel 7 string Freeswitch
+ATTRIBUTE Freeswitch-Ani 8 string Freeswitch
+ATTRIBUTE Freeswitch-Aniii 9 string Freeswitch
+ATTRIBUTE Freeswitch-Lastapp 10 string Freeswitch
+ATTRIBUTE Freeswitch-Lastdata 11 string Freeswitch
+ATTRIBUTE Freeswitch-Disposition 12 string Freeswitch
+ATTRIBUTE Freeswitch-Hangupcause 13 integer Freeswitch
+ATTRIBUTE Freeswitch-Billusec 15 integer Freeswitch
+ATTRIBUTE Freeswitch-AMAFlags 16 integer Freeswitch
+ATTRIBUTE Freeswitch-RDNIS 17 string Freeswitch
+ATTRIBUTE Freeswitch-Context 18 string Freeswitch
+ATTRIBUTE Freeswitch-Source 19 string Freeswitch
+ATTRIBUTE Freeswitch-Callstartdate 20 string Freeswitch
+ATTRIBUTE Freeswitch-Callanswerdate 21 string Freeswitch
+ATTRIBUTE Freeswitch-Calltransferdate 22 string Freeswitch
+ATTRIBUTE Freeswitch-Callenddate 23 string Freeswitch
+
+#
+# Freeswitch-Hangupcause
+#
+VALUE Freeswitch-Hangupcause None 0
+VALUE Freeswitch-Hangupcause Unallocated-Number 1
+VALUE Freeswitch-Hangupcause No-Route-Transit-Net 2
+VALUE Freeswitch-Hangupcause No-Route-Destination 3
+VALUE Freeswitch-Hangupcause Channel-Unacceptable 6
+VALUE Freeswitch-Hangupcause Call-Awarded-Delivery 7
+VALUE Freeswitch-Hangupcause Normal-Clearing 16
+VALUE Freeswitch-Hangupcause User-Busy 17
+VALUE Freeswitch-Hangupcause No-User-Response 18
+VALUE Freeswitch-Hangupcause No-Answer 19
+VALUE Freeswitch-Hangupcause Subscriber-Absent 20
+VALUE Freeswitch-Hangupcause Call-Rejected 21
+VALUE Freeswitch-Hangupcause Number-Changed 22
+VALUE Freeswitch-Hangupcause Redirecto-To-New-Destination 23
+VALUE Freeswitch-Hangupcause Exchange-Routing-Error 25
+VALUE Freeswitch-Hangupcause Destination-Out-Of-Order 27
+VALUE Freeswitch-Hangupcause Invalid-Number-Format 28
+VALUE Freeswitch-Hangupcause Facility-Rejected 29
+VALUE Freeswitch-Hangupcause Response-To-Status-Enquiry 30
+VALUE Freeswitch-Hangupcause Normal-Unspecified 31
+VALUE Freeswitch-Hangupcause Normal-Circuit-Congestion 34
+VALUE Freeswitch-Hangupcause Network-Out-Of-Order 38
+VALUE Freeswitch-Hangupcause Normal-Temporary-Failure 41
+VALUE Freeswitch-Hangupcause Switch-Congestion 42
+VALUE Freeswitch-Hangupcause Access-Info-Discarded 43
+VALUE Freeswitch-Hangupcause Requested-Chan-Unavail 44
+VALUE Freeswitch-Hangupcause Pre-Empted 45
+VALUE Freeswitch-Hangupcause Facility-Not-Subscribed 50
+VALUE Freeswitch-Hangupcause Outgoing-Call-Barred 52
+VALUE Freeswitch-Hangupcause Incoming-Call-Barred 54
+VALUE Freeswitch-Hangupcause Bearercapability-Notauth 57
+VALUE Freeswitch-Hangupcause Bearercapability-Notavail 58
+VALUE Freeswitch-Hangupcause Service-Unavailable 63
+VALUE Freeswitch-Hangupcause Bearercapability-Notimpl 65
+VALUE Freeswitch-Hangupcause Chan-Not-Implemented 66
+VALUE Freeswitch-Hangupcause Facility-Not-Implemented 69
+VALUE Freeswitch-Hangupcause Service-Not-Implemented 79
+VALUE Freeswitch-Hangupcause Invalid-Call-Reference 81
+VALUE Freeswitch-Hangupcause Incompatible-Destination 88
+VALUE Freeswitch-Hangupcause Invalid-Msg-Unspecified 95
+VALUE Freeswitch-Hangupcause Mandatory-IE-Missing 96
+VALUE Freeswitch-Hangupcause Message-Type-Nonexist 97
+VALUE Freeswitch-Hangupcause Wrong-Message 98
+VALUE Freeswitch-Hangupcause IE-Nonexist 99
+VALUE Freeswitch-Hangupcause Invalid-IE-Contents 100
+VALUE Freeswitch-Hangupcause Wrong-Call-State 101
+VALUE Freeswitch-Hangupcause Recovery-On-Timer-Expire 102
+VALUE Freeswitch-Hangupcause Mandatory-IE-Length-Error 103
+VALUE Freeswitch-Hangupcause Protocol-Error 111
+VALUE Freeswitch-Hangupcause Interworking 127
+VALUE Freeswitch-Hangupcause Success 142
+VALUE Freeswitch-Hangupcause Originator-Cancel 487
+VALUE Freeswitch-Hangupcause Crash 500
+VALUE Freeswitch-Hangupcause System-Shutdown 501
+VALUE Freeswitch-Hangupcause Lose-Race 502
+VALUE Freeswitch-Hangupcause Manager-Request 503
+VALUE Freeswitch-Hangupcause Blind-Transfer 600
+VALUE Freeswitch-Hangupcause Attended-Transfer 601
+VALUE Freeswitch-Hangupcause Allotted-Timeout 602
+VALUE Freeswitch-Hangupcause User-Challenge 603
+VALUE Freeswitch-Hangupcause Media-Timeout 604
+VALUE Freeswitch-Hangupcause Picked-Off 605
+VALUE Freeswitch-Hangupcause User-Not-Registered 606
+
+#
+#
+#
+
+END-VENDOR Freeswitch
+
+#ATTRIBUTE Digest-Response 206 string
+#ATTRIBUTE Digest-Attributes 207 octets # stupid format
+
+
1
0
[Freeswitch-svn] [commit] r14035 - in freeswitch/trunk/contrib/cparker: . mod_xml_radius mod_xml_radius/conf mod_xml_radius/conf/xml_radius_templates
by FreeSWITCH SVN 29 Jun '09
by FreeSWITCH SVN 29 Jun '09
29 Jun '09
Author: cparker
Date: Mon Jun 29 15:51:08 2009
New Revision: 14035
Log:
Adding cparker contrib directory, with first stab at mod_xml_radius
Added:
freeswitch/trunk/contrib/cparker/
freeswitch/trunk/contrib/cparker/mod_xml_radius/
freeswitch/trunk/contrib/cparker/mod_xml_radius/Makefile.am
freeswitch/trunk/contrib/cparker/mod_xml_radius/README
freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/
freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/README
freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/mod_xml_radius.conf.xml
freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/xml_radius_templates/
freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/xml_radius_templates/directory.xml
freeswitch/trunk/contrib/cparker/mod_xml_radius/mod_xml_radius.c
freeswitch/trunk/contrib/cparker/mod_xml_radius/mod_xml_radius.h
Added: freeswitch/trunk/contrib/cparker/mod_xml_radius/Makefile.am
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/cparker/mod_xml_radius/Makefile.am Mon Jun 29 15:51:08 2009
@@ -0,0 +1,33 @@
+AM_CFLAGS = $(SWITCH_AM_CFLAGS)
+AM_CPPFLAGS = $(SWITCH_AM_CXXFLAGS)
+AM_LDFLAGS = $(SWITCH_AM_LDFLAGS)
+#we should set all these vars from configure, no reason to have these in each Makefile.am
+LIBTOOL = echo "`link=\`echo $@|grep .la;echo $@|grep .so;echo $@|grep .dll\`;if test -n "$$link"; then echo Creating $@;fi`";`if test -z "$(VERBOSE)" ; \
+then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(SHELL) $(switch_builddir)/libtool; fi`
+AM_MAKEFLAGS=`test -n "$(VERBOSE)" || echo -s`
+# Dirty trick to override the link output
+LIBS+=> $(MODNAME).log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat $(MODNAME).log;fi;if test "$$error" = "yes";then exit 1;fi
+
+moddir=$(prefix)/mod
+
+MODNAME=mod_xml_radius
+mod_LTLIBRARIES = mod_xml_radius.la
+mod_xml_radius_la_SOURCES = mod_xml_radius.c
+mod_xml_radius_la_CFLAGS = $(AM_CFLAGS)
+mod_xml_radius_la_CPPFLAGS = $(AM_CPPFLAGS)
+mod_xml_radius_la_LIBADD=$(switch_builddir)/libfreeswitch.la
+mod_xml_radius_la_LDFLAGS=-module -avoid-version -no-undefined
+
+mod_xml_radius_la_LDFLAGS += -lfreeradius-client
+
+#Override the linstall target so we just install the .so/.dylib
+
+install-data-am: $(DESTDIR)$(PREFIX)/$(moddir)/$(MODNAME).$(DYNAMIC_LIB_EXTEN)
+
+$(DESTDIR)$(PREFIX)/$(moddir)/$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).la
+ @echo installing $(MODNAME).$(DYNAMIC_LIB_EXTEN)
+ @if [ -f .libs/$(MODNAME).$(DYNAMIC_LIB_EXTEN) ] ; then \
+ $(LIBTOOL) --mode=install $(INSTALL) .libs/$(MODNAME).$(DYNAMIC_LIB_EXTEN) $(DESTDIR)$(PREFIX)/$(moddir) >/dev/null ; \
+ else \
+ $(LIBTOOL) --mode=install $(INSTALL) $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(DESTDIR)$(PREFIX)/$(moddir) >/dev/null ; \
+ fi
Added: freeswitch/trunk/contrib/cparker/mod_xml_radius/README
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/cparker/mod_xml_radius/README Mon Jun 29 15:51:08 2009
@@ -0,0 +1,20 @@
+THIS MODULE IS HIGHLY EXPERIMENTAL. USE MAY RESULT IN HAIR LOSS, DISMEMBERMENT,
+OR EVEN DEATH.
+
+
+That out of the way, it is a way to provide a RADIUS interface to perform
+authentication and authorization functionality to FreeSWITCH.
+
+It uses the FreeRADIUS Client Library, which is part of the FreeRADIUS project.
+The version used to create/test this library is the tagged release 1.1.6.
+
+In order to use this module, you will need to edit the top level 'configure.in'
+as well as 'modules.conf'.
+
+More information/details can be found on the wiki:
+
+ http://wiki.freeswitch.org/wiki/Mod_xml_radius
+
+Questions/comments/suggestions, please find 's3g_fault' on IRC.
+
+
Added: freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/README
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/README Mon Jun 29 15:51:08 2009
@@ -0,0 +1 @@
+Install/copy these into /usr/local/freeswitch/conf/autoload_configs
Added: freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/mod_xml_radius.conf.xml
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/mod_xml_radius.conf.xml Mon Jun 29 15:51:08 2009
@@ -0,0 +1,48 @@
+<configuration name="mod_xml_radius.conf" description="XML RADIUS Configuration">
+ <bindings>
+ <binding name="directory"/>
+ <!-- <binding name="dialplan"/> -->
+ </bindings>
+ <settings>
+ <!-- location of the radius dictionary file -->
+ <param name="dictionary" value="/usr/local/freeswitch/conf/radius/dictionary"/>
+ <!-- location of the radius sequence file -->
+ <param name="seqfile" value="/var/run/radius_auth.seq"/>
+
+ <!-- accounting servers, up to 8 allowed -->
+ <!-- value is "host:port:secret", port is optional -->
+ <!-- use IP ADDRESSES, not hostnames -->
+ <param name="authserver" value="127.0.0.1:1812:testing123"/>
+ <!--<param name="authserver" value="10.0.0.254:1813:testing123"/> -->
+ <!--<param name="authserver" value="192.168.10.10:1813:testing123"/> -->
+
+ <!-- number of retries for each server -->
+ <param name="radius_retries" value="3"/>
+ <!-- number of seconds to wait between retries -->
+ <param name="radius_timeout" value="5"/>
+ <!-- The length of time in seconds that we skip a nonresponsive RADIUS
+ server for transaction requests. Server(s) being in the "dead" state
+ are tried only after all other non-dead servers have been tried and
+ failed or timeouted. The deadtime interval starts when the server
+ does not respond to an authentication/accounting request transmissions.
+ When the interval expires, the "dead" server would be re-tried again,
+ and if it's still down then it will be considered "dead" for another
+ such interval and so on. This option is no-op if there is only one
+ server in the list. Set to 0 in order to disable the feature. -->
+ <param name="radius_deadtime" value="0"/>
+ </settings>
+ <templates>
+
+ <template name="not_found">
+ <document type="freeswitch/xml">
+ <section name="result">
+ <result status="not found"/>
+ </section>
+ </document>
+ </template>
+
+ <X-PRE-PROCESS cmd="include" data="xml_radius_templates/*.xml"/>
+
+ </templates>
+</configuration>
+
Added: freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/xml_radius_templates/directory.xml
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/cparker/mod_xml_radius/conf/xml_radius_templates/directory.xml Mon Jun 29 15:51:08 2009
@@ -0,0 +1,25 @@
+<include>
+ <template name="directory">
+ <document type="freeswitch/xml">
+ <section name="directory" description="arbitrary stuff here">
+<domain name="${domain}">
+ <groups>
+ <group name="default">
+ <users>
+ <user id="${user}" number-alias="${radius_alias}">
+ <params>
+ <param name="vm-password" value="${radius_vm_pass}"/>
+ </params>
+ <variables>
+ <variable name="international" value="${radius_international}"/>
+ <variable name="usenat" value="${radius_natuser}"/>
+ </variables>
+ </user>
+ </users>
+ </group>
+ </groups>
+ </domain>
+ </section>
+ </document>
+ </template>
+</include>
Added: freeswitch/trunk/contrib/cparker/mod_xml_radius/mod_xml_radius.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/cparker/mod_xml_radius/mod_xml_radius.c Mon Jun 29 15:51:08 2009
@@ -0,0 +1,632 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2009, Anthony Minessale II <anthm(a)freeswitch.org>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthm(a)freeswitch.org>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Anthony Minessale II <anthm(a)freeswitch.org>
+ * Chris Parker <cparker(a)segv.org>
+ *
+ * mod_xml_radius.c -- use radius to realtime create xml directory, dialplan bindings
+ *
+ */
+#include <switch.h>
+#include <sys/stat.h>
+#include <freeradius-client.h>
+#include "mod_xml_radius.h"
+
+typedef enum {
+ XML_RADIUS_DIRECTORY = 0,
+ XML_RADIUS_DIALPLAN = 0,
+} xml_radius_query_type_t;
+
+#define XML_RADIUS_SYNTAX "[debug_on|debug_off]"
+
+static char cf[] = "mod_xml_radius.conf";
+static char my_dictionary[PATH_MAX];
+static char my_seqfile[PATH_MAX];
+static char *my_deadtime; /* 0 */
+static char *my_timeout; /* 5 */
+static char *my_retries; /* 3 */
+static char my_servers[SERVER_MAX][255];
+
+static struct {
+ int shutdown;
+ switch_memory_pool_t *pool;
+ switch_mutex_t *mutex;
+ switch_thread_rwlock_t *rwlock;
+ switch_xml_t templates_tag;
+} globals;
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_xml_radius_load);
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_radius_shutdown);
+SWITCH_MODULE_DEFINITION(mod_xml_radius, mod_xml_radius_load, mod_xml_radius_shutdown, NULL);
+
+static switch_bool_t debug = SWITCH_FALSE;
+
+static int logi = 0;
+static void logger(char *str)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "DEBUG[%i] [%s]\n", ++logi, str);
+}
+
+
+static rc_handle *my_radius_init(void)
+{
+ int i = 0;
+ rc_handle *rad_config;
+
+ rad_config = rc_new();
+
+ if (rad_config == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Error initializing rc_handle!\n");
+ return NULL;
+ }
+
+ rad_config = rc_config_init(rad_config);
+
+ if (rad_config == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error initializing radius config!\n");
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+ /* Some hardcoded ( for now ) defaults needed to initialize radius */
+ if (rc_add_config(rad_config, "auth_order", "radius", "mod_xml_radius.c", 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting auth_order = radius failed\n");
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+ if (rc_add_config(rad_config, "seqfile", my_seqfile, "mod_xml_radius.c", 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting seqfile = %s failed\n", my_seqfile);
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+
+ /* Add the module configs to initialize rad_config */
+
+ for (i = 0; i < SERVER_MAX && my_servers[i][0] != '\0'; i++) {
+ if (rc_add_config(rad_config, "authserver", my_servers[i], cf, 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting authserver = %s failed\n", my_servers[i]);
+ rc_destroy(rad_config);
+ return NULL;
+ }
+ }
+
+ if (rc_add_config(rad_config, "dictionary", my_dictionary, cf, 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed setting dictionary = %s failed\n", my_dictionary);
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+ if (rc_add_config(rad_config, "radius_deadtime", my_deadtime, cf, 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting radius_deadtime = %s failed\n", my_deadtime);
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+ if (rc_add_config(rad_config, "radius_timeout", my_timeout, cf, 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting radius_timeout = %s failed\n", my_timeout);
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+ if (rc_add_config(rad_config, "radius_retries", my_retries, cf, 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting radius_retries = %s failed\n", my_retries);
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+ /* Read the dictionary file(s) */
+ if (rc_read_dictionary(rad_config, rc_conf_str(rad_config, "dictionary")) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "reading dictionary file(s): %s\n", my_dictionary);
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+ return rad_config;
+}
+
+
+SWITCH_STANDARD_API(xml_radius_function)
+{
+ if (session) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (switch_strlen_zero(cmd)) {
+ goto usage;
+ }
+
+ if (!strcasecmp(cmd, "debug_on")) {
+ debug = SWITCH_TRUE;
+ } else if (!strcasecmp(cmd, "debug_off")) {
+ debug = SWITCH_FALSE;
+ } else {
+ goto usage;
+ }
+
+ stream->write_function(stream, "OK\n");
+ return SWITCH_STATUS_SUCCESS;
+
+ usage:
+ stream->write_function(stream, "USAGE: %s\n", XML_RADIUS_SYNTAX);
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+typedef struct xml_binding {
+ char *bindings;
+} xml_binding_t;
+
+
+static switch_status_t xml_radius_expand_tag(switch_xml_t xml_in, switch_event_t *params, switch_xml_t xml_out, int *off)
+{
+ switch_xml_t xml_in_tmp = NULL;
+ int i;
+
+ if (switch_strlen_zero(xml_out->name)) {
+ xml_out->name = strdup(xml_in->name);
+ } else if (!(xml_out = switch_xml_add_child_d(xml_out, xml_in->name, *off++))) {
+ return SWITCH_STATUS_FALSE;
+ }
+ for (i = 0; xml_in->attr[i]; i+=2) {
+ char *tmp_attr;
+ tmp_attr = switch_event_expand_headers(params, xml_in->attr[i+1]);
+ switch_xml_set_attr(xml_out, xml_in->attr[i], tmp_attr);
+ }
+ for (xml_in_tmp = xml_in->child; xml_in_tmp; xml_in_tmp = xml_in_tmp->ordered) {
+ xml_radius_expand_tag(xml_in_tmp, params, xml_out, off);
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_status_t xml_radius_expand_template(char *template_name, switch_event_t *params, switch_xml_t xml_out, int *off)
+{
+ switch_xml_t template_tag = NULL, sub_tag = NULL;
+
+ for (template_tag = switch_xml_child(globals.templates_tag, "template"); template_tag; template_tag = template_tag->next) {
+ char *template_tag_name = (char*) switch_xml_attr_soft(template_tag, "name");
+ if (!strcmp(template_tag_name, template_name)) {
+ for (sub_tag = template_tag->child; sub_tag; sub_tag = sub_tag->ordered) {
+ xml_radius_expand_tag(sub_tag, params, xml_out, off);
+ }
+ return SWITCH_STATUS_SUCCESS;
+ }
+ }
+ return SWITCH_STATUS_FALSE;
+}
+
+
+
+static switch_xml_t xml_radius_search(const char *section, const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, void *user_data)
+{
+ xml_binding_t *binding = (xml_binding_t *) user_data;
+ switch_event_header_t *hi;
+ xml_radius_query_type_t query_type;
+ switch_event_t *rad_event;
+ rc_handle *rad_config;
+ VALUE_PAIR *send = NULL;
+ VALUE_PAIR *received = NULL;
+ VALUE_PAIR *vp = NULL;
+ char msg[4096];
+ uint32_t client_port = 0;
+ char *uuid_str, *user_name, *digest_response, *digest_realm, *digest_nonce, *digest_cnonce,
+ *digest_method, *digest_uri, *digest_algorithm, *digest_username, *digest_qop, *digest_nc ;
+
+ switch_xml_t xml_out = NULL;
+ if ((xml_out = switch_xml_new(""))) {
+ //switch_xml_set_attr_d(xml_out, "document type", "freeswitch/xml");
+ }
+
+ /*int off = 0; */
+ int off = 0, ret = 1;
+
+ if (debug) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DEBUG in xml_radius_search Section: %s, Tag: %s, Key: %s, Value: %s\n", section, tag_name, key_name, key_value);
+ }
+
+ if (!binding) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No bindings... sorry bud returning now\n");
+ return NULL;
+ }
+ if (!strcmp(section, "directory")) {
+ query_type = XML_RADIUS_DIRECTORY;
+ } else if (!strcmp(section, "dialplan")) {
+ query_type = XML_RADIUS_DIALPLAN;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid section: %s\n", section);
+ return NULL;
+ }
+
+ if (params) {
+ if ((hi = params->headers)) {
+ for (; hi; hi = hi->next) {
+ if (debug == SWITCH_TRUE) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "DEBUG in xml_radius_search, header [%s]=[%s]\n", hi->name, hi->value);
+ }
+ }
+ //xml_odbc_render_template(globals.template, params, xml_out, &off); // TODO globals.template should be replace with something specific for this section
+ }
+ } else {
+ goto cleanup;
+ }
+
+ uuid_str = switch_event_get_header(params, "Core-UUID");
+ digest_response = switch_event_get_header(params, "sip_auth_response");
+ digest_realm = switch_event_get_header(params, "sip_auth_realm");
+ digest_nonce = switch_event_get_header(params, "sip_auth_nonce");
+ digest_cnonce = switch_event_get_header(params, "sip_auth_cnonce");
+ digest_method = switch_event_get_header(params, "sip_auth_method");
+ digest_uri = switch_event_get_header(params, "sip_auth_uri");
+ digest_algorithm = switch_event_get_header(params, "sip_auth_algorithm");
+ digest_username = switch_event_get_header(params, "sip_auth_username");
+ digest_qop = switch_event_get_header(params, "sip_auth_qop");
+ digest_nc = switch_event_get_header(params, "sip_auth_nc");
+
+ if(digest_algorithm == NULL) {
+ digest_algorithm = switch_mprintf("MD5");
+ }
+
+ if( (uuid_str == NULL) ||
+ (digest_response == NULL) ||
+ (digest_realm == NULL) ||
+ (digest_nonce == NULL) ||
+ (digest_method == NULL) ||
+ (digest_uri == NULL) ||
+ (digest_algorithm == NULL) ||
+ (digest_username == NULL)
+ ) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "[mod_xml_radius] Insufficient headers to perform digest auth\n");
+ /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s:%s:%s:%s:%s:%s:%s:%s", uuid_str, digest_response, digest_realm, digest_nonce, digest_method, digest_uri, digest_algorithm, digest_username); */
+ return NULL;
+ }
+
+
+ user_name = switch_mprintf("%s@%s", digest_username, digest_realm);
+
+ /* Initialize RADIUS and add attributes to the AUTH REQUEST packet */
+
+ if(switch_event_dup(&rad_event, params) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed creating radius event.\n");
+ return NULL;
+ }
+
+ switch_thread_rwlock_rdlock(globals.rwlock);
+
+ rad_config = my_radius_init();
+
+ if (rad_config == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Error initializing radius\n");
+ goto cleanup;
+ }
+
+ if (rc_avpair_add(rad_config, &send, PW_ACCT_SESSION_ID, uuid_str, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Acct-Session-ID: %s\n", uuid_str);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+
+ if (rc_avpair_add(rad_config, &send, PW_USER_NAME, user_name, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding User-Name: %s\n", user_name);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_RESPONSE, digest_response, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest Response: %s\n", digest_response);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_REALM, digest_realm, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest Realm: %s\n", digest_realm);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_NONCE, digest_nonce, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest Nonce: %s\n", digest_nonce);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+
+ if(digest_cnonce != NULL) {
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_CNONCE, digest_cnonce, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest CNonce: %s\n", digest_cnonce);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Missing Digest CNonce\n");
+ }
+
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_METHOD, digest_method, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest Method: %s\n", digest_method);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_URI, digest_uri, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest URI: %s\n", digest_uri);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_ALGORITHM, digest_algorithm, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest Algorithm: %s\n", digest_algorithm);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_USER_NAME, digest_username, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest Username: %s\n", digest_username);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+
+ if(digest_qop != NULL) {
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_QOP, digest_qop, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest QOP: %s\n", digest_qop);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Missing Digest QOP.\n");
+ }
+
+
+ if(digest_nc != NULL) {
+ if (rc_avpair_add(rad_config, &send, PW_DIGEST_NONCE_COUNT, digest_nc, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed adding Digest Nonce Counce: %s\n", digest_nc);
+ rc_destroy(rad_config);
+ goto cleanup;
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Missing Nonce Count.\n");
+ }
+
+ /* SEND IT! */
+
+ if(rc_auth(rad_config, client_port, send, &received, msg) == OK_RC) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Auth Success.\n");
+
+ char name[2048], value[2048]; /* more than enough for radius attribute */
+ char *split[2];
+ /* walk the received radius value-pairs and print them out */
+ vp = received;
+ while(vp) {
+ strncpy(name, "radius_", 7);
+ rc_avpair_tostr(rad_config, vp, name+7, sizeof(name)-7, value, sizeof(value));
+ if(debug == SWITCH_TRUE) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "[mod_xml_radius] Received AVP: %s = %s\n", name, value);
+ }
+ /* if name = Freeradius-AVPair then value contains a 'name="value"' string we need to parse out */
+ if(strcmp(name,"Freeradius-AVPair")) {
+ if(switch_separate_string(value,'=',split, (sizeof(split) / sizeof(split[0]))) == 2) {
+ strncpy(name+7, split[0], sizeof(name)-7);
+ strncpy(value, split[1], sizeof(value));
+ }
+ }
+ if(switch_event_add_header_string(rad_event, SWITCH_STACK_BOTTOM, name, value) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Failed to add header: %s = %s\n", name, value);
+ }
+ vp = vp->next;
+
+ }
+
+ if(query_type == XML_RADIUS_DIRECTORY) {
+ xml_radius_expand_template("directory", rad_event, xml_out, &off);
+ } else if(query_type == XML_RADIUS_DIALPLAN) {
+ xml_radius_expand_template("dialplan", rad_event, xml_out, &off);
+ }
+
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_xml_radius] Auth Rejected!\n");
+
+ /* TO DO: Generate the Failure XML Here fromt the Reply Attributes */
+
+ /* Return "NOT FOUND" template */
+
+ xml_radius_expand_template("not_found", rad_event, xml_out, &off);
+
+ }
+
+ if ((hi = rad_event->headers)) {
+ for (; hi; hi = hi->next) {
+ if (debug == SWITCH_TRUE) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "DEBUG in xml_radius_search, new haeader [%s]=[%s]\n", hi->name, hi->value);
+ }
+ }
+ }
+
+ rc_destroy(rad_config);
+ rc_avpair_free(send);
+ rc_avpair_free(received);
+
+ /* End of RADIUS bits */
+
+ if (debug == SWITCH_TRUE) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Debug dump of XML generated:\n%s", switch_xml_toxml(xml_out, SWITCH_FALSE));
+ }
+
+ ret = 0;
+
+ cleanup:
+
+ switch_event_destroy(&rad_event);
+ switch_thread_rwlock_unlock(globals.rwlock);
+
+ if (ret) {
+ switch_xml_free(xml_out);
+ return NULL;
+ }
+
+ return xml_out;
+}
+
+
+static switch_status_t load_config(void)
+{
+ switch_xml_t cfg, xml, bindings_tag, binding_tag, templates_tag, settings, param;
+ xml_binding_t *binding = NULL;
+
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+ int num_servers = 0;
+ int i = 0;
+
+ my_timeout = "5";
+ my_retries = "3";
+ my_deadtime = "0";
+ strncpy(my_seqfile, "/var/run/radius_auth.seq", PATH_MAX - 1);
+ strncpy(my_dictionary, "/usr/local/freeswitch/conf/radius/dictionary", PATH_MAX - 1);
+
+ for (i = 0; i < SERVER_MAX; i++) {
+ my_servers[i][0] = '\0';
+ }
+
+ if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
+ return SWITCH_STATUS_TERM;
+ }
+
+
+ if (!(bindings_tag = switch_xml_child(cfg, "bindings"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <bindings> tag!\n");
+ status = SWITCH_STATUS_TERM;
+ goto done;
+ }
+
+ if (!(templates_tag = switch_xml_child(cfg, "templates"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <templates> tag!\n");
+ status = SWITCH_STATUS_TERM;
+ goto done;
+ }
+
+ globals.templates_tag = templates_tag;
+
+ for (binding_tag = switch_xml_child(bindings_tag, "binding"); binding_tag; binding_tag = binding_tag->next) {
+ char *bname = (char*) switch_xml_attr_soft(binding_tag, "name");
+ if (!(binding = malloc(sizeof(*binding)))) {
+ goto done;
+ }
+ memset(binding, 0, sizeof(*binding));
+
+ binding->bindings = strdup(bname);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML RADIUS Fetch Function [%s]\n",
+ switch_strlen_zero(bname) ? "N/A" : bname, binding->bindings ? binding->bindings : "all");
+ switch_xml_bind_search_function(xml_radius_search, switch_xml_parse_section_string(bname), binding);
+ binding = NULL;
+ }
+
+ if ((settings = switch_xml_child(cfg, "settings"))) {
+ for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcmp(var, "authserver")) {
+ if (num_servers < SERVER_MAX) {
+ strncpy(my_servers[num_servers], val, 255 - 1);
+ num_servers++;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "you can only specify %d radius servers, ignoring excess server entry\n", SERVER_MAX);
+ }
+ } else if (!strcmp(var, "dictionary")) {
+ strncpy(my_dictionary, val, PATH_MAX - 1);
+ } else if (!strcmp(var, "seqfile")) {
+ strncpy(my_seqfile, val, PATH_MAX - 1);
+ } else if (!strcmp(var, "radius_timeout")) {
+ my_timeout = strdup(val);
+ } else if (!strcmp(var, "radius_retries")) {
+ my_retries = strdup(val);
+ } else if (!strcmp(var, "radius_deadtime")) {
+ my_deadtime = strdup(val);
+ }
+ }
+ }
+ switch_xml_free(xml);
+
+ if (num_servers < 1) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "you must specify at least 1 radius server\n");
+ return SWITCH_STATUS_TERM;
+ }
+
+ done:
+
+ return status;
+}
+
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_xml_radius_load)
+{
+
+ switch_core_new_memory_pool(&globals.pool);
+ switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
+
+ switch_api_interface_t *xml_radius_api_interface;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "XML RADIUS module loading...\n");
+
+ *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+
+ SWITCH_ADD_API(xml_radius_api_interface, "xml_radius", "XML RADIUS", xml_radius_function, XML_RADIUS_SYNTAX);
+ switch_console_set_complete("add xml_radius debug_on");
+ switch_console_set_complete("add xml_radius debug_off");
+ //switch_console_set_complete("add xml_odbc render_template");
+
+ switch_thread_rwlock_create(&globals.rwlock, pool);
+
+ if (load_config() != SWITCH_STATUS_SUCCESS) {
+ return SWITCH_STATUS_TERM;
+ }
+
+ /* indicate that the module should continue to be loaded */
+ return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_radius_shutdown)
+{
+
+ globals.shutdown = 1;
+ switch_thread_rwlock_wrlock(globals.rwlock);
+ switch_thread_rwlock_unlock(globals.rwlock);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
+ */
Added: freeswitch/trunk/contrib/cparker/mod_xml_radius/mod_xml_radius.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/contrib/cparker/mod_xml_radius/mod_xml_radius.h Mon Jun 29 15:51:08 2009
@@ -0,0 +1,63 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application Call Detail Recorder module
+ * Copyright 2006, Author: Yossi Neiman of Cartis Solutions, Inc. <freeswitch AT cartissolutions.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application Call Detail Recorder module
+ *
+ * The Initial Developer of the Original Code is
+ * Chris Parker <cparker AT segv.org>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Chris Parker <cparker AT segv.org>
+ *
+ * Description: Contains definitions and structs used by the radius cdr module.
+ *
+ * mod_radius_cdr.h
+ *
+ */
+
+#ifndef MODRADIUSCDR
+#define MODRADIUSCDR
+
+#define PW_FS_PEC 27880
+
+#define PW_FS_AVPAIR 1
+#define PW_FS_CLID 2
+#define PW_FS_DIALPLAN 3
+#define PW_FS_SRC 4
+#define PW_FS_DST 5
+#define PW_FS_SRC_CHANNEL 6
+#define PW_FS_DST_CHANNEL 7
+#define PW_FS_ANI 8
+#define PW_FS_ANIII 9
+#define PW_FS_LASTAPP 10
+#define PW_FS_LASTDATA 11
+#define PW_FS_DISPOSITION 12
+#define PW_FS_HANGUPCAUSE 13
+#define PW_FS_BILLUSEC 15
+#define PW_FS_AMAFLAGS 16
+#define PW_FS_RDNIS 17
+#define PW_FS_CONTEXT 18
+#define PW_FS_SOURCE 19
+#define PW_FS_CALLSTARTDATE 20
+#define PW_FS_CALLANSWERDATE 21
+#define PW_FS_CALLTRANSFERDATE 22
+#define PW_FS_CALLENDDATE 23
+
+
+#endif
1
0