Freeswitch-trunk
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 2007
- 7 participants
- 182 discussions
[commit] r5373 - in freeswitch/trunk/src/mod/languages: mod_spidermonkey mod_spidermonkey_core_db mod_spidermonkey_etpan mod_spidermonkey_odbc mod_spidermonkey_skel mod_spidermonkey_teletone
by Freeswitch SVN 15 Jun '07
by Freeswitch SVN 15 Jun '07
15 Jun '07
Author: anthm
Date: Fri Jun 15 13:05:20 2007
New Revision: 5373
Modified:
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c
Log:
Avoiding Initial SegFault *now with lycopene!*
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Fri Jun 15 13:05:20 2007
@@ -45,10 +45,6 @@
SWITCH_MODULE_DEFINITION(mod_spidermonkey, mod_spidermonkey_load, mod_spidermonkey_shutdown, NULL);
#define METHOD_SANITY_CHECK() do { \
-if (jss->sanity_code != SANITY_CODE_VAL) { \
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Object! Avoiding Initial SegFault!\n"); \
- return JS_TRUE; \
- } \
if (!jss || !jss->session) { \
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n"); \
*rval = BOOLEAN_TO_JSVAL(JS_FALSE); \
@@ -84,7 +80,7 @@
static JSClass global_class = {
"Global", JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
@@ -299,7 +295,7 @@
JSClass request_class = {
"Request", JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, request_getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, request_getProperty, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, request_destroy, NULL, NULL, NULL, NULL
};
@@ -604,7 +600,7 @@
JSClass event_class = {
"Event", JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, event_getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, event_getProperty, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, event_destroy, NULL, NULL, NULL,
event_construct
};
@@ -2040,6 +2036,7 @@
{0}
};
+
static JSBool session_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
@@ -2133,7 +2130,7 @@
JSClass session_class = {
"Session", JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, session_getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, session_getProperty, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, session_destroy, NULL, NULL, NULL,
session_construct
};
@@ -2149,7 +2146,6 @@
jss->cx = cx;
jss->obj = session_obj;
jss->stack_depth = 0;
- jss->sanity_code = SANITY_CODE_VAL;
if ((JS_SetPrivate(cx, session_obj, jss) &&
JS_DefineProperties(cx, session_obj, session_props) && JS_DefineFunctions(cx, session_obj, session_methods))) {
return session_obj;
@@ -2170,7 +2166,6 @@
memset(jss, 0, sizeof(*jss));
jss->cx = cx;
jss->obj = obj;
- jss->sanity_code = SANITY_CODE_VAL;
switch_set_flag(jss, S_FREE);
JS_SetPrivate(cx, obj, jss);
@@ -2513,7 +2508,7 @@
JSClass fileio_class = {
"FileIO", JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, fileio_getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, fileio_getProperty, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, fileio_destroy, NULL, NULL, NULL,
fileio_construct
};
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h Fri Jun 15 13:05:20 2007
@@ -122,7 +122,6 @@
typedef struct sm_module_interface sm_module_interface_t;
typedef switch_status_t (*spidermonkey_init_t) (const sm_module_interface_t ** module_interface);
-#define SANITY_CODE_VAL 424242
struct js_session {
switch_core_session_t *session;
JSContext *cx;
@@ -132,9 +131,13 @@
JSFunction *on_hangup;
int stack_depth;
switch_channel_state_t hook_state;
- int sanity_code;
};
+JSBool DEFAULT_SET_PROPERTY(JSContext * cx, JSObject *obj, jsval id, jsval *vp)
+{
+ return JS_FALSE;
+}
+
SWITCH_END_EXTERN_C
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c Fri Jun 15 13:05:20 2007
@@ -268,7 +268,7 @@
JSClass db_class = {
modname, JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, db_getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, db_getProperty, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, db_destroy, NULL, NULL, NULL,
db_construct
};
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c Fri Jun 15 13:05:20 2007
@@ -216,7 +216,7 @@
JSClass etpan_class = {
modname, JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, etpan_getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, etpan_getProperty, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, etpan_destroy, NULL, NULL, NULL,
etpan_construct
};
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c Fri Jun 15 13:05:20 2007
@@ -438,7 +438,7 @@
JSClass odbc_class = {
modname, JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, odbc_getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, odbc_getProperty, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, odbc_destroy, NULL, NULL, NULL,
odbc_construct
};
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c Fri Jun 15 13:05:20 2007
@@ -74,7 +74,7 @@
JSClass skel_class = {
modname, JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, skel_getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, skel_getProperty, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, skel_destroy, NULL, NULL, NULL,
skel_construct
};
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c Fri Jun 15 13:05:20 2007
@@ -331,7 +331,7 @@
JSClass teletone_class = {
modname, JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, teletone_getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, teletone_getProperty, DEFAULT_SET_PROPERTY,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, teletone_destroy, NULL, NULL, NULL,
teletone_construct
};
1
0
[commit] r5372 - in freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr: . radius
by Freeswitch SVN 15 Jun '07
by Freeswitch SVN 15 Jun '07
15 Jun '07
Author: cparker
Date: Fri Jun 15 10:38:45 2007
New Revision: 5372
Added:
freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.conf.xml
freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/radius/
freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/radius/dictionary
Modified:
freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/README
Log:
Updated build instructions and added sample config files
Modified: freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/README
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/README (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/README Fri Jun 15 10:38:45 2007
@@ -34,16 +34,16 @@
event_handlers/mod_radius_cdr
...
-3) Re-run configure ??? ( does this need to be done? )
+3) Re-run configure ??? ( does this need to be done???)
-4) Run make
+4) Run make, and make install. Make sure the module is built and installed.
-5) Edit freeswitch configuration
+5) Configure FreeSWITCH to load it
- - Make sure the module is loaded
- - Make sure the module XML config file is included
-
-6) Edit the module config file for your system specifics ( servers, secrets, etc. )
+ - Copy the 'mod_radius_cdr.conf.xml' file to the FreeSWITCH conf directory
+ - Copy the 'radius/' directory to the FreeSWITCH conf directory
+ - Edit 'conf/modules.conf' to load mod_radius_cdr
+ - Edit 'conf/freeswitch.xml' to include 'mod_radius_cdr.conf.xml'
=========================================================================================
Added: freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.conf.xml
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.conf.xml Fri Jun 15 10:38:45 2007
@@ -0,0 +1,17 @@
+<configuration name="mod_radius_cdr.conf" description="RADIUS CDR Configuration">
+ <settings>
+ <!-- location of the radius dictionary files -->
+ <param name="dictionary" value="/usr/local/freeswitch/conf/radius/dictionary"/>
+ <!-- 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"/>
+ <!-- accounting servers, up to 8 allowed -->
+ <!-- value is "host:port:secret", port is optional -->
+ <!-- use IP ADDRESSES, not hostnames -->
+ <param name="acct_server" value="127.0.0.1:1813:testing123"/>
+ <param name="acct_server" value="10.0.0.254:1813:testing123"/>
+ <param name="acct_server" value="192.168.10.10:1813:testing123"/>
+ </settings>
+</configuration>
+
Added: freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/radius/dictionary
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/radius/dictionary Fri Jun 15 10:38:45 2007
@@ -0,0 +1,347 @@
+#
+# 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
+
+#
+# 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-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 Unallocated 0
+VALUE Freeswitch-Hangupcause Success 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-ID-Length-Error 103
+VALUE Freeswitch-Hangupcause Protocol-Error 111
+VALUE Freeswitch-Hangupcause Interworking 127
+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
+
+
+
+#
+#
+#
+
+
+END-VENDOR Freeswitch
1
0
[commit] r5371 - freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr
by Freeswitch SVN 15 Jun '07
by Freeswitch SVN 15 Jun '07
15 Jun '07
Author: cparker
Date: Fri Jun 15 10:31:02 2007
New Revision: 5371
Added:
freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/README
Log:
README file documenting how to build mod_radius_cdr in current trunk, as it is not built by default
Added: freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/README
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/README Fri Jun 15 10:31:02 2007
@@ -0,0 +1,84 @@
+mod_radius_cdr - A cdr Accounting module for FreeSWITCH.
+
+cparker at segv dot org
+
+=========================================================================================
+
+Currently, this is in it's infancy, and is still being worked on. It is not
+yet enabled by default in building.
+
+Comments, code, patches are always welcome. :)
+
+=========================================================================================
+
+Pre-reqs:
+
+In order to use this module you will need to have the CVS head of the freeradius-client
+library installed.
+
+CVS version as of June 14, 2007 or later will be sufficient.
+
+Instructions on how to retrieve and install this can be found here:
+
+ http://wiki.freeradius.org/Radiusclient
+
+=========================================================================================
+
+Building:
+
+1) Compile and install freeradius-client library.
+
+2) Edit the top-level 'modules.conf'. Add the following entry:
+
+...
+event_handlers/mod_radius_cdr
+...
+
+3) Re-run configure ??? ( does this need to be done? )
+
+4) Run make
+
+5) Edit freeswitch configuration
+
+ - Make sure the module is loaded
+ - Make sure the module XML config file is included
+
+6) Edit the module config file for your system specifics ( servers, secrets, etc. )
+
+=========================================================================================
+
+Here's a sample RADIUS transaction ( logged to a detail file via FreeRADIUS server ):
+
+Fri Jun 8 08:23:10 2007
+ Acct-Status-Type = Start
+ Acct-Session-Id = "d734ff5e-bf04-4045-8cb3-f5744574808b"
+ Freeswitch-Src = "8478797989"
+ Freeswitch-CLID = "Chris Parker"
+ Freeswitch-Dst = "888"
+ Freeswitch-Dialplan = "XML"
+ NAS-Port = 0
+ Acct-Delay-Time = 0
+ NAS-IP-Address = 127.0.0.1
+ Client-IP-Address = 127.0.0.1
+ Acct-Unique-Session-Id = "4b7754541b5902fa"
+ Timestamp = 1181308990
+
+Fri Jun 8 08:23:31 2007
+ Acct-Status-Type = Stop
+ Acct-Session-Id = "d734ff5e-bf04-4045-8cb3-f5744574808b"
+ Freeswitch-Hangupcause = Normal-Clearing
+ Freeswitch-Src = "8478797989"
+ Freeswitch-CLID = "Chris Parker"
+ Freeswitch-Dst = "888"
+ Freeswitch-Dialplan = "XML"
+ Freeswitch-Lastapp = "bridge"
+ Freeswitch-Billusec = 21460442
+ NAS-Port = 0
+ Acct-Delay-Time = 0
+ NAS-IP-Address = 127.0.0.1
+ Client-IP-Address = 127.0.0.1
+ Acct-Unique-Session-Id = "4b7754541b5902fa"
+ Timestamp = 1181309011
+
+
+
1
0
[commit] r5370 - freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr
by Freeswitch SVN 15 Jun '07
by Freeswitch SVN 15 Jun '07
15 Jun '07
Author: cparker
Date: Fri Jun 15 10:15:24 2007
New Revision: 5370
Added:
freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/Makefile.am
freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c
freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h
Log:
Initial mod_radius_cdr merge into trunk
Added: freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/Makefile.am
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/Makefile.am Fri Jun 15 10:15:24 2007
@@ -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_radius_cdr
+mod_LTLIBRARIES = mod_radius_cdr.la
+mod_radius_cdr_la_SOURCES = mod_radius_cdr.c
+mod_radius_cdr_la_CFLAGS = $(AM_CFLAGS) -l
+mod_radius_cdr_la_CPPFLAGS = $(AM_CPPFLAGS)
+mod_radius_cdr_la_LIBADD=$(switch_builddir)/libfreeswitch.la
+mod_radius_cdr_la_LDFLAGS=-module -avoid-version -no-undefined
+
+mod_radius_cdr_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/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c Fri Jun 15 10:15:24 2007
@@ -0,0 +1,503 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct(a)yahoo.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
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthmct(a)yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Chris Parker <cparker(a)segv.org>
+ *
+ *
+ * mod_radius_cdr.c -- RADIUS CDR Module
+ *
+ */
+
+#define _BSD_SOURCE 1
+
+#include <switch.h>
+#include <sys/stat.h>
+#include <freeradius-client.h>
+#include "mod_radius_cdr.h"
+
+static const char modname[] = "mod_radius_cdr";
+
+static char cf[] = "mod_radius_cdr.conf";
+static char my_dictionary[PATH_MAX];
+static char * my_timeout; /* 5 */
+static char * my_retries; /* 3 */
+static char my_servers[SERVER_MAX][255];
+
+static rc_handle * my_radius_init(void)
+{
+ rc_handle *rad_config;
+
+ rad_config = rc_new();
+
+ if (rad_config == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] 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, "[mod_radius_cdr] 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_radius_cdr.c", 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "[mod_radius_cdr] failed setting auth_order = radius\n");
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+ if (rc_add_config(rad_config, "seqfile", "/var/run/radius.seq", "mod_radius_cdr.c", 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed setting seqfile = /var/run/radius.seq\n");
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+
+ /* Add the module configs to initialize rad_config */
+
+ for (int i = 0; i < SERVER_MAX && my_servers[i][0] != '\0'; i++) {
+ if (rc_add_config(rad_config, "acctserver", my_servers[i], cf, 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting acctserver = %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_timeout", my_timeout, cf, 0) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed 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,
+ "failed 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,
+ "failed reading dictionary file(s): %s\n", my_dictionary);
+ rc_destroy(rad_config);
+ return NULL;
+ }
+
+ return rad_config;
+}
+
+static switch_status_t my_on_ring(switch_core_session_t *session)
+{
+ switch_xml_t cdr;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ rc_handle *rad_config;
+ int retval = 0;
+ VALUE_PAIR *send = NULL;
+ UINT4 client_port = 0;
+ UINT4 status_type = PW_STATUS_START;
+
+ char *uuid_str;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] Entering my_on_ring\n");
+
+ rad_config = my_radius_init();
+
+ if (rad_config == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] Error initializing radius, Start packet not logged.\n");
+ return SWITCH_STATUS_TERM;
+ }
+
+ if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
+ uuid_str = switch_core_session_get_uuid(session);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] Error Generating Data!\n");
+ return SWITCH_STATUS_TERM;
+ }
+
+ /* Create the radius packet */
+
+ /* Set Status Type */
+ if (rc_avpair_add(rad_config, &send, PW_ACCT_STATUS_TYPE, &status_type, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] Failed setting Acct-Status-Type: Start\n");
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+
+ 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_radius_cdr] Failed adding Acct-Session-ID: %s\n", uuid_str);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+
+ /* Add VSAs */
+
+ if(channel) {
+ /*switch_call_cause_t cause;*/
+ switch_caller_profile_t *profile;
+
+ /*
+ cause = switch_channel_get_cause(channel);
+ if (rc_avpair_add(rad_config, &send, PW_FS_HANGUPCAUSE, &cause, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-Hangupcause: %d\n", cause);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ */
+
+ profile = switch_channel_get_caller_profile(channel);
+
+ if(profile) {
+ if(profile->caller_id_number) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_SRC, profile->caller_id_number, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Src: %s\n", profile->caller_id_number);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->caller_id_name) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_CLID, profile->caller_id_name, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-CLID: %s\n", profile->caller_id_name);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->destination_number) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_DST, profile->destination_number, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Dst: %s\n", profile->destination_number);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->dialplan) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_DIALPLAN, profile->dialplan, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Dialplan: %s\n", profile->dialplan);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->caller_extension && profile->caller_extension->last_application->application_name) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_LASTAPP,
+ profile->caller_extension->last_application->application_name, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Lastapp: %s\n", profile->source);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "profile == NULL\n");
+ }
+ }
+
+ if(rc_acct(rad_config, client_port, send) == OK_RC) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] RADIUS Accounting OK\n");
+ retval = SWITCH_STATUS_SUCCESS;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] RADIUS Accounting Failed\n");
+ retval = SWITCH_STATUS_TERM;
+ }
+ rc_avpair_free(send);
+
+ return(retval);
+}
+
+static switch_status_t my_on_hangup(switch_core_session_t *session)
+{
+ switch_xml_t cdr;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ rc_handle *rad_config;
+ int retval = 0;
+ VALUE_PAIR *send = NULL;
+ UINT4 client_port = 0;
+ UINT4 status_type = PW_STATUS_STOP;
+ switch_time_t callstartdate = 0;
+ switch_time_t callanswerdate = 0;
+ switch_time_t callenddate = 0;
+ switch_time_t calltransferdate = 0;
+ switch_time_t billusec = 0;
+ UINT4 billsec = 0;
+ char *uuid_str;
+
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[mod_radius_cdr] Entering my_on_hangup\n");
+
+ rad_config = my_radius_init();
+
+ if (rad_config == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] Error initializing radius, session not logged.\n");
+ return SWITCH_STATUS_TERM;
+ }
+
+ if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
+ uuid_str = switch_core_session_get_uuid(session);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] Error Generating Data!\n");
+ return SWITCH_STATUS_TERM;
+ }
+
+ /* Create the radius packet */
+
+ /* Set Status Type */
+ if (rc_avpair_add(rad_config, &send, PW_ACCT_STATUS_TYPE, &status_type, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Acct-Session-ID: %s\n", uuid_str);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+
+ 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, "failed adding Acct-Session-ID: %s\n", uuid_str);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+
+ /* Add VSAs */
+
+ if(channel) {
+ switch_call_cause_t cause;
+ switch_caller_profile_t *profile;
+
+ cause = switch_channel_get_cause(channel);
+ if (rc_avpair_add(rad_config, &send, PW_FS_HANGUPCAUSE, &cause, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-Hangupcause: %d\n", cause);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+
+ profile = switch_channel_get_caller_profile(channel);
+
+ if(profile) {
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[mod_radius_cdr] Calculating billable time\n");
+
+ /* calculate billable time */
+ callstartdate = profile->times->created;
+ callanswerdate = profile->times->answered;
+ calltransferdate = profile->times->transferred;
+ callenddate = profile->times->hungup;
+
+ if(switch_channel_test_flag(channel,CF_ANSWERED)) {
+ if(callstartdate && callanswerdate) {
+ if(callenddate)
+ billusec = callenddate - callanswerdate;
+ else if(calltransferdate)
+ billusec = calltransferdate - callanswerdate;
+ }
+ }
+ else if(switch_channel_test_flag(channel,CF_TRANSFER)) {
+ if(callanswerdate && calltransferdate)
+ billusec = calltransferdate - callanswerdate;
+ }
+ billsec = (billusec / 1000000);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[mod_radius_cdr] Finished calculating billable time\n");
+
+ if(profile->caller_id_number) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_SRC, profile->caller_id_number, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Src: %s\n", profile->caller_id_number);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->caller_id_name) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_CLID, profile->caller_id_name, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-CLID: %s\n", profile->caller_id_name);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->destination_number) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_DST, profile->destination_number, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Dst: %s\n", profile->destination_number);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->dialplan) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_DIALPLAN, profile->dialplan, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Dialplan: %s\n", profile->dialplan);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->caller_extension && profile->caller_extension->last_application->application_name) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_LASTAPP,
+ profile->caller_extension->last_application->application_name, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Lastapp: %s\n", profile->source);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if (rc_avpair_add(rad_config, &send, PW_FS_BILLUSEC, &billusec, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Billusec: %u\n", (UINT4)billusec);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ if (rc_avpair_add(rad_config, &send, PW_ACCT_SESSION_TIME, &billsec, -1, 0) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Acct-Session-Time: %u\n", billsec);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ } else { /* no profile, can't create data to send */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "profile == NULL\n");
+ }
+ }
+
+ if(rc_acct(rad_config, client_port, send) == OK_RC) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RADIUS Accounting OK\n");
+ retval = SWITCH_STATUS_SUCCESS;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RADIUS Accounting Failed\n");
+ retval = SWITCH_STATUS_TERM;
+ }
+ rc_avpair_free(send);
+
+ return(retval);
+}
+
+static switch_status_t load_config(void)
+{
+ switch_xml_t cfg, xml, settings, param;
+
+ int num_servers = 0;
+
+ my_timeout = "5";
+ my_retries = "3";
+
+ for( int 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 ((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, "acctserver")) {
+ 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, "radius_timeout")) {
+ my_timeout = strdup(val);
+ }
+ else if (!strcmp(var, "radius_retries")) {
+ my_retries = 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;
+ }
+
+ /* If we made it this far, we succeeded */
+ return SWITCH_STATUS_SUCCESS;
+}
+
+static const switch_state_handler_table_t state_handlers = {
+ /*.on_init */ NULL,
+ /*.on_ring */ my_on_ring,
+ /*.on_execute */ NULL,
+ /*.on_hangup */ my_on_hangup,
+ /*.on_loopback */ NULL,
+ /*.on_transmit */ NULL
+};
+
+
+static const switch_loadable_module_interface_t mod_radius_cdr_module_interface = {
+ /*.module_name = */ modname,
+ /*.endpoint_interface = */ NULL,
+ /*.timer_interface = */ NULL,
+ /*.dialplan_interface = */ NULL,
+ /*.codec_interface = */ NULL,
+ /*.application_interface */ NULL
+};
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+{
+ if (load_config() != SWITCH_STATUS_SUCCESS) {
+ return SWITCH_STATUS_TERM;
+ }
+
+ /* test global state handlers */
+ switch_core_add_state_handler(&state_handlers);
+
+ *module_interface = &mod_radius_cdr_module_interface;
+
+ /* indicate that the module should continue to be loaded */
+ 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 expandtab:
+ */
Added: freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h Fri Jun 15 10:15:24 2007
@@ -0,0 +1,59 @@
+/*
+ * 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_CALLSTARTDATE 20
+#define PW_FS_CALLANSWERDATE 21
+#define PW_FS_CALLTRANSFERDATE 22
+#define PW_FS_CALLENDDATE 23
+
+#endif
1
0
15 Jun '07
Author: anthm
Date: Fri Jun 15 04:14:55 2007
New Revision: 5369
Modified:
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
Log:
fix potential crash from malformed js
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Fri Jun 15 04:14:55 2007
@@ -37,11 +37,33 @@
#ifdef HAVE_CURL
#include <curl/curl.h>
#endif
+static int foo = 0;
+
SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown);
SWITCH_MODULE_DEFINITION(mod_spidermonkey, mod_spidermonkey_load, mod_spidermonkey_shutdown, NULL);
+#define METHOD_SANITY_CHECK() do { \
+if (jss->sanity_code != SANITY_CODE_VAL) { \
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Object! Avoiding Initial SegFault!\n"); \
+ return JS_TRUE; \
+ } \
+if (!jss || !jss->session) { \
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n"); \
+ *rval = BOOLEAN_TO_JSVAL(JS_FALSE); \
+ return JS_TRUE; \
+ } \
+ } while(foo == 1)
+
+#define CHANNEL_SANITY_CHECK() do { \
+ if (!switch_channel_ready(channel)) { \
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n"); \
+ *rval = BOOLEAN_TO_JSVAL(JS_FALSE); \
+ return JS_TRUE; \
+ } \
+ } while (foo == 1)
+
static void session_destroy(JSContext * cx, JSObject * obj);
static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
@@ -818,11 +840,9 @@
uintN argc = 0;
jsval argv[4];
JSObject *Event = NULL;
+ jsval nval , *rval = &nval;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- return SWITCH_STATUS_FALSE;
- }
+ METHOD_SANITY_CHECK();
jss->stack_depth++;
@@ -1012,11 +1032,7 @@
switch_size_t has;
switch_channel_t *channel;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1067,20 +1083,12 @@
int32 limit = 0;
switch_input_args_t args = { 0 };
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ CHANNEL_SANITY_CHECK();
if (argc > 0) {
@@ -1150,21 +1158,12 @@
switch_input_args_t args = { 0 };
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
-
+ CHANNEL_SANITY_CHECK();
if (argc > 0) {
if ((function = JS_ValueToFunction(cx, argv[0]))) {
@@ -1217,21 +1216,12 @@
JSFunction *function;
switch_input_args_t args = { 0 };
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
-
+ CHANNEL_SANITY_CHECK();
if (argc > 0) {
phrase_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -1360,20 +1350,12 @@
switch_input_args_t args = { 0 };
char *prebuf;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ CHANNEL_SANITY_CHECK();
if (argc > 0) {
@@ -1433,11 +1415,7 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1503,21 +1481,12 @@
JSFunction *function;
switch_input_args_t args = { 0 };
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
-
+ CHANNEL_SANITY_CHECK();
if (argc > 0) {
tts_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -1571,21 +1540,12 @@
int32 digits = 0, timeout = 5000;
switch_channel_t *channel;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
-
+ CHANNEL_SANITY_CHECK();
if (argc > 0) {
char term;
@@ -1617,11 +1577,7 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
if (argv[0]) {
JSBool tf;
@@ -1642,21 +1598,12 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
-
+ CHANNEL_SANITY_CHECK();
switch_channel_answer(channel);
return JS_TRUE;
@@ -1671,10 +1618,7 @@
/*Always a pessimist... sheesh! */
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
if (switch_ivr_generate_xml_cdr(jss->session, &cdr) == SWITCH_STATUS_SUCCESS) {
char *xml_text;
@@ -1693,11 +1637,7 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1717,11 +1657,7 @@
unsigned int elapsed;
int32 timeout = 60;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1760,11 +1696,7 @@
unsigned int elapsed;
int32 timeout = 60;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1799,20 +1731,13 @@
switch_channel_t *channel;
struct js_session *jss = JS_GetPrivate(cx, obj);
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+
+ CHANNEL_SANITY_CHECK();
if (argc > 1) {
@@ -1822,11 +1747,7 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
jsrefcount saveDepth;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
if (application_interface->application_function) {
@@ -1847,11 +1768,7 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_event_t *event;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
if (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
JSObject *Event;
@@ -1881,11 +1798,7 @@
JSObject *Event;
struct event_obj *eo;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
if (argc > 0) {
if (JS_ValueToObject(cx, argv[0], &Event)) {
@@ -1913,20 +1826,12 @@
char *cause_name = NULL;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
- if (!jss || !jss->session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
- }
+ CHANNEL_SANITY_CHECK();
if (argc > 1) {
cause_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -2244,6 +2149,7 @@
jss->cx = cx;
jss->obj = session_obj;
jss->stack_depth = 0;
+ jss->sanity_code = SANITY_CODE_VAL;
if ((JS_SetPrivate(cx, session_obj, jss) &&
JS_DefineProperties(cx, session_obj, session_props) && JS_DefineFunctions(cx, session_obj, session_methods))) {
return session_obj;
@@ -2264,6 +2170,7 @@
memset(jss, 0, sizeof(*jss));
jss->cx = cx;
jss->obj = obj;
+ jss->sanity_code = SANITY_CODE_VAL;
switch_set_flag(jss, S_FREE);
JS_SetPrivate(cx, obj, jss);
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h Fri Jun 15 04:14:55 2007
@@ -122,6 +122,7 @@
typedef struct sm_module_interface sm_module_interface_t;
typedef switch_status_t (*spidermonkey_init_t) (const sm_module_interface_t ** module_interface);
+#define SANITY_CODE_VAL 424242
struct js_session {
switch_core_session_t *session;
JSContext *cx;
@@ -131,6 +132,7 @@
JSFunction *on_hangup;
int stack_depth;
switch_channel_state_t hook_state;
+ int sanity_code;
};
1
0
15 Jun '07
Author: anthm
Date: Thu Jun 14 22:58:11 2007
New Revision: 5368
Modified:
freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
Log:
fix spelling err
Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c Thu Jun 14 22:58:11 2007
@@ -111,7 +111,8 @@
uint32_t samples_per_frame;
int dtmf_on;
int dtmf_off;
- int suppres_dtmf_tone;
+ int suppress_dtmf_tone;
+ int ignore_dtmf_tone;
int configured_spans;
int configured_boost_spans;
char *dialplan;
@@ -524,8 +525,11 @@
tech_pvt->tone_session.rate = rate;
tech_pvt->tone_session.duration = globals.dtmf_on * (tech_pvt->tone_session.rate / 1000);
tech_pvt->tone_session.wait = globals.dtmf_off * (tech_pvt->tone_session.rate / 1000);
+
+ if (!globals.ignore_dtmf_tone) {
+ teletone_dtmf_detect_init (&tech_pvt->dtmf_detect, rate);
+ }
- teletone_dtmf_detect_init (&tech_pvt->dtmf_detect, rate);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio init %s\n", switch_channel_get_name(channel));
switch_set_flag(tech_pvt, TFLAG_CODEC);
@@ -786,25 +790,26 @@
tech_pvt->read_frame.datalen = bytes;
tech_pvt->read_frame.samples = bytes / 2;
-
- teletone_dtmf_detect (&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
- teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
- if(digit_str[0]) {
- switch_channel_queue_dtmf(channel, digit_str);
- if (globals.debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", digit_str);
- }
- if (globals.suppres_dtmf_tone) {
- tech_pvt->skip_read_frames = 20;
+ if (!globals.ignore_dtmf_tone) {
+ teletone_dtmf_detect (&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
+ teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
+
+ if(digit_str[0]) {
+ switch_channel_queue_dtmf(channel, digit_str);
+ if (globals.debug) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", digit_str);
+ }
+ if (globals.suppress_dtmf_tone) {
+ tech_pvt->skip_read_frames = 20;
+ }
}
- }
- if (tech_pvt->skip_read_frames > 0) {
- memset(tech_pvt->read_frame.data, 0, tech_pvt->read_frame.datalen);
- tech_pvt->skip_read_frames--;
+ if (tech_pvt->skip_read_frames > 0) {
+ memset(tech_pvt->read_frame.data, 0, tech_pvt->read_frame.datalen);
+ tech_pvt->skip_read_frames--;
+ }
}
-
#ifdef DOTRACE
write(tech_pvt->fd2, tech_pvt->read_frame.data, (int) tech_pvt->read_frame.datalen);
#endif
@@ -2220,8 +2225,10 @@
globals.dtmf_off = atoi(val);
} else if (!strcmp(var, "dialplan")) {
set_global_dialplan(val);
- } else if (!strcmp(var, "suppres-dtmf-tone")) {
- globals.suppres_dtmf_tone = switch_true(val);
+ } else if (!strcmp(var, "suppress-dtmf-tone")) {
+ globals.suppress_dtmf_tone = switch_true(val);
+ } else if (!strcmp(var, "ignore-dtmf-tone")) {
+ globals.ignore_dtmf_tone = switch_true(val);
}
}
}
1
0
15 Jun '07
Author: anthm
Date: Thu Jun 14 22:48:20 2007
New Revision: 5367
Modified:
freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
Log:
fix spelling err
Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c Thu Jun 14 22:48:20 2007
@@ -111,7 +111,7 @@
uint32_t samples_per_frame;
int dtmf_on;
int dtmf_off;
- int supress_dtmf_tone;
+ int suppres_dtmf_tone;
int configured_spans;
int configured_boost_spans;
char *dialplan;
@@ -795,7 +795,7 @@
if (globals.debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", digit_str);
}
- if (globals.supress_dtmf_tone) {
+ if (globals.suppres_dtmf_tone) {
tech_pvt->skip_read_frames = 20;
}
}
@@ -2220,8 +2220,8 @@
globals.dtmf_off = atoi(val);
} else if (!strcmp(var, "dialplan")) {
set_global_dialplan(val);
- } else if (!strcmp(var, "supress-dtmf-tone")) {
- globals.supress_dtmf_tone = switch_true(val);
+ } else if (!strcmp(var, "suppres-dtmf-tone")) {
+ globals.suppres_dtmf_tone = switch_true(val);
}
}
}
1
0
[commit] r5366 - in freeswitch/trunk/src: . include mod/applications/mod_commands mod/applications/mod_dptools mod/applications/mod_soundtouch
by Freeswitch SVN 15 Jun '07
by Freeswitch SVN 15 Jun '07
15 Jun '07
Author: anthm
Date: Thu Jun 14 21:47:48 2007
New Revision: 5366
Modified:
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp
freeswitch/trunk/src/switch_core_codec.c
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_ivr_async.c
Log:
add session_displace api and app
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Thu Jun 14 21:47:48 2007
@@ -200,6 +200,9 @@
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh);
+SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags);
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, char *file);
+
/*!
\brief Stop Recording a session
\param session the session to stop recording
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 Thu Jun 14 21:47:48 2007
@@ -565,7 +565,7 @@
goto usage;
}
- if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) != 3) {
+ if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 3) {
goto usage;
}
@@ -609,6 +609,73 @@
return SWITCH_STATUS_SUCCESS;
}
+
+SWITCH_STANDARD_API(session_displace_function)
+{
+ switch_core_session_t *rsession = NULL;
+ char *mycmd = NULL, *argv[5] = { 0 };
+ char *uuid = NULL, *action = NULL, *path = NULL;
+ int argc = 0;
+ uint32_t limit = 0;
+ char *flags = NULL;
+
+ if (session) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (switch_strlen_zero(cmd)) {
+ goto usage;
+ }
+
+ if (!(mycmd = strdup(cmd))) {
+ goto usage;
+ }
+
+ if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 3) {
+ goto usage;
+ }
+
+ uuid = argv[0];
+ action = argv[1];
+ path = argv[2];
+ limit = argv[3] ? atoi(argv[3]) : 0;
+ flags = argv[4];
+
+ if (!(rsession = switch_core_session_locate(uuid))) {
+ stream->write_function(stream, "-Error Cannot locate session!\n");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
+ goto usage;
+ }
+
+ if (!strcasecmp(action, "start")) {
+ switch_ivr_displace_session(rsession, path, limit, flags);
+ } else if (!strcasecmp(action, "stop")) {
+ switch_ivr_stop_displace_session(rsession, path);
+ } else {
+ goto usage;
+ }
+
+ goto done;
+
+ usage:
+
+ stream->write_function(stream, "INVALID SYNTAX\n");
+ switch_safe_free(mycmd);
+
+
+ done:
+
+ if (rsession) {
+ switch_core_session_rwunlock(rsession);
+ }
+
+ switch_safe_free(mycmd);
+ return SWITCH_STATUS_SUCCESS;
+}
+
SWITCH_STANDARD_API(pause_function)
{
switch_core_session_t *psession = NULL;
@@ -1237,12 +1304,20 @@
/*.next */ &broadcast_api_interface
};
+static switch_api_interface_t session_displace_api_interface = {
+ /*.interface_name */ "session_displace",
+ /*.desc */ "session displace",
+ /*.function */ session_displace_function,
+ /*.syntax */ "<uuid> [start|stop] <path> [<limit>] [mux]",
+ /*.next */ &broadcast_api_interface
+};
+
static switch_api_interface_t uuid_bridge_api_interface = {
/*.interface_name */ "uuid_bridge",
/*.desc */ "uuid_bridge",
/*.function */ uuid_bridge_function,
/*.syntax */ "<uuid> <other_uuid>",
- /*.next */ &session_record_api_interface
+ /*.next */ &session_displace_api_interface
};
static switch_api_interface_t status_api_interface = {
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Thu Jun 14 21:47:48 2007
@@ -789,6 +789,43 @@
}
+static void displace_session_function(switch_core_session_t *session, char *data)
+{
+ switch_channel_t *channel;
+ char *path = NULL;
+ uint32_t limit = 0;
+ char *argv[6];
+ int x, argc;
+ char *lbuf = NULL;
+ char *flags = NULL;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ if (data && (lbuf = switch_core_session_strdup(session, data))
+ && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+ path = argv[0];
+ for(x = 0; x < argc; x++) {
+ if (strchr(argv[x], '+')) {
+ limit = atoi(argv[x]);
+ } else if (!switch_strlen_zero(argv[x])) {
+ flags = argv[x];
+ }
+ }
+ switch_ivr_displace_session(session, path, limit, flags);
+ }
+}
+
+
+static void stop_displace_session_function(switch_core_session_t *session, char *data)
+{
+ switch_channel_t *channel;
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ switch_ivr_stop_displace_session(session, data);
+}
+
static void record_function(switch_core_session_t *session, char *data)
{
@@ -995,6 +1032,26 @@
&bridge_application_interface
};
+static switch_application_interface_t displace_application_interface = {
+ /*.interface_name */ "displace",
+ /*.application_function */ displace_session_function,
+ /* long_desc */ "Displace audio from a file to the channels input",
+ /* short_desc */ "Displace File",
+ /* syntax */ "<path> [+time_limit_ms] [mux]",
+ /* flags */ SAF_NONE,
+ &speak_application_interface
+};
+
+static switch_application_interface_t stop_displace_application_interface = {
+ /*.interface_name */ "displace",
+ /*.application_function */ stop_displace_session_function,
+ /* long_desc */ "Stop Displacing to a file",
+ /* short_desc */ "Stop Displace File",
+ /* syntax */ "<path>",
+ /* flags */ SAF_NONE,
+ &displace_application_interface
+};
+
static switch_application_interface_t record_application_interface = {
/*.interface_name */ "record",
/*.application_function */ record_function,
@@ -1002,7 +1059,7 @@
/* short_desc */ "Record File",
/* syntax */ "<path> [+time_limit_ms]",
/* flags */ SAF_NONE,
- &speak_application_interface
+ &stop_displace_application_interface
};
Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp (original)
+++ freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp Thu Jun 14 21:47:48 2007
@@ -257,8 +257,13 @@
char *lbuf = NULL;
int x;
- if (switch_channel_get_private(channel, "_soundtouch_")) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
+ if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
+ if (!switch_strlen_zero(data) && !strcasecmp(data, "stop")) {
+ switch_channel_set_private(channel, "_soundtouch_", NULL);
+ switch_core_media_bug_remove(session, &bug);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
+ }
return;
}
Modified: freeswitch/trunk/src/switch_core_codec.c
==============================================================================
--- freeswitch/trunk/src/switch_core_codec.c (original)
+++ freeswitch/trunk/src/switch_core_codec.c Thu Jun 14 21:47:48 2007
@@ -50,6 +50,8 @@
session->read_codec = codec;
session->raw_read_frame.codec = session->read_codec;
session->raw_write_frame.codec = session->read_codec;
+ session->enc_read_frame.codec = session->read_codec;
+ session->enc_write_frame.codec = session->read_codec;
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Thu Jun 14 21:47:48 2007
@@ -241,7 +241,7 @@
do_bugs = 0;
if (bp->callback) {
bp->read_replace_frame_in = read_frame;
- bp->read_replace_frame_out = NULL;
+ bp->read_replace_frame_out = read_frame;
if ((ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_REPLACE)) == SWITCH_TRUE) {
read_frame = bp->read_replace_frame_out;
}
@@ -509,7 +509,7 @@
do_bugs = 0;
if (bp->callback) {
bp->write_replace_frame_in = write_frame;
- bp->write_replace_frame_out = NULL;
+ bp->write_replace_frame_out = write_frame;
if ((ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_WRITE_REPLACE)) == SWITCH_TRUE) {
write_frame = bp->write_replace_frame_out;
}
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Thu Jun 14 21:47:48 2007
@@ -96,6 +96,151 @@
}
+typedef struct {
+ switch_file_handle_t fh;
+ int mux;
+} displace_helper_t;
+
+static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+{
+ displace_helper_t *dh = (displace_helper_t *) user_data;
+ uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
+ switch_frame_t frame = { 0 };
+
+ frame.data = data;
+ frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
+
+ switch (type) {
+ case SWITCH_ABC_TYPE_INIT:
+ break;
+ case SWITCH_ABC_TYPE_CLOSE:
+ if (dh) {
+ switch_core_file_close(&dh->fh);
+ }
+ break;
+ case SWITCH_ABC_TYPE_READ_REPLACE:
+ {
+ switch_frame_t *frame = switch_core_media_bug_get_read_replace_frame(bug);
+ if (dh && !dh->mux) {
+ memset(frame->data, 255, frame->datalen);
+ }
+ switch_core_media_bug_set_read_replace_frame(bug, frame);
+ }
+ break;
+ case SWITCH_ABC_TYPE_WRITE_REPLACE:
+ if (dh) {
+ switch_frame_t *frame = NULL;
+ switch_size_t len;
+
+ frame = switch_core_media_bug_get_write_replace_frame(bug);
+ len = frame->samples;
+
+ if (dh->mux) {
+ int16_t buf[1024];
+ int16_t *fp = frame->data;
+ int x;
+
+ switch_core_file_read(&dh->fh, buf, &len);
+
+ for(x = 0; x < len; x++) {
+ int32_t mixed = fp[x] + buf[x];
+ switch_normalize_to_16bit(mixed);
+ fp[x] = (int16_t) mixed;
+ }
+ } else {
+ switch_core_file_read(&dh->fh, frame->data, &len);
+ frame->samples = len;
+ frame->datalen = frame->samples * 2;
+ }
+ switch_core_media_bug_set_write_replace_frame(bug, frame);
+ }
+ break;
+ case SWITCH_ABC_TYPE_WRITE:
+ default:
+ break;
+ }
+
+ return SWITCH_TRUE;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, char *file)
+{
+ switch_media_bug_t *bug;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+
+ assert(channel != NULL);
+ if ((bug = switch_channel_get_private(channel, file))) {
+ switch_channel_set_private(channel, file, NULL);
+ switch_core_media_bug_remove(session, &bug);
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags)
+{
+ switch_channel_t *channel;
+ switch_codec_t *read_codec;
+ switch_media_bug_t *bug;
+ switch_status_t status;
+ time_t to = 0;
+ displace_helper_t *dh;
+
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ if ((bug = switch_channel_get_private(channel, file))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Only 1 of the same file per channel please!\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (!(dh = switch_core_session_alloc(session, sizeof(*dh)))) {
+ return SWITCH_STATUS_MEMERR;
+ }
+
+
+
+ read_codec = switch_core_session_get_read_codec(session);
+ assert(read_codec != NULL);
+
+ dh->fh.channels = read_codec->implementation->number_of_channels;
+ dh->fh.samplerate = read_codec->implementation->samples_per_second;
+
+
+ if (switch_core_file_open(&dh->fh,
+ file,
+ read_codec->implementation->number_of_channels,
+ read_codec->implementation->samples_per_second,
+ SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+ switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ switch_core_session_reset(session);
+ return SWITCH_STATUS_GENERR;
+ }
+
+ switch_channel_answer(channel);
+
+ if (limit) {
+ to = time(NULL) + limit;
+ }
+
+ if (flags && strchr(flags, 'm')) {
+ dh->mux++;
+ }
+
+ if ((status = switch_core_media_bug_add(session, displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
+ switch_core_file_close(&dh->fh);
+ return status;
+ }
+
+ switch_channel_set_private(channel, file, bug);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
{
@@ -158,14 +303,20 @@
switch_status_t status;
time_t to = 0;
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ if ((bug = switch_channel_get_private(channel, file))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Only 1 of the same file per channel please!\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
if (!fh) {
if (!(fh = switch_core_session_alloc(session, sizeof(*fh)))) {
return SWITCH_STATUS_MEMERR;
}
}
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
read_codec = switch_core_session_get_read_codec(session);
assert(read_codec != NULL);
1
0
14 Jun '07
Author: anthm
Date: Thu Jun 14 17:03:17 2007
New Revision: 5364
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/switch_rtp.c
Log:
set control for vad from vars
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Jun 14 17:03:17 2007
@@ -913,6 +913,20 @@
uint8_t vad_out = switch_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0;
uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
+ if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_enable_vad_in")) && switch_true(val)) {
+ vad_in = 1;
+ }
+ if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_enable_vad_out")) && switch_true(val)) {
+ vad_out = 1;
+ }
+
+ if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_disable_vad_in")) && switch_true(val)) {
+ vad_in = 0;
+ }
+ if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_disable_vad_out")) && switch_true(val)) {
+ vad_out = 0;
+ }
+
tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
switch_set_flag_locked(tech_pvt, TFLAG_RTP);
switch_set_flag_locked(tech_pvt, TFLAG_IO);
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Thu Jun 14 17:03:17 2007
@@ -1435,6 +1435,10 @@
rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
}
switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void *) send_msg, &bytes);
+ } else if (!fwd) {
+ /* nevermind save this seq inc for next time */
+ rtp_session->seq--;
+ rtp_session->send_msg.header.seq = htons(rtp_session->seq);
}
if (rtp_session->ice_user) {
1
0
14 Jun '07
Author: mikej
Date: Thu Jun 14 11:24:20 2007
New Revision: 5359
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
merge patch from MODAPP-15 with 2 changes as discussed with the submitter:
add missing part of if for starting sound.
add a file stop specific to async and only stop the async file play.
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Thu Jun 14 11:24:20 2007
@@ -57,7 +57,8 @@
typedef enum {
FILE_STOP_CURRENT,
- FILE_STOP_ALL
+ FILE_STOP_ALL,
+ FILE_STOP_ASYNC
} file_stop_t;
/* Global Values */
@@ -179,6 +180,7 @@
char *exit_sound;
char *alone_sound;
char *perpetual_sound;
+ char *moh_sound;
char *ack_sound;
char *nack_sound;
char *muted_sound;
@@ -503,8 +505,14 @@
switch_event_fire(&event);
}
- if (conference->count > 1 && conference->enter_sound) {
- conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
+ if (conference->count > 1) {
+ if(conference->moh_sound) {
+ /* stop MoH if any */
+ conference_stop_file(conference, FILE_STOP_ASYNC);
+ }
+ if(conference->enter_sound) {
+ conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
+ }
}
channel = switch_core_session_get_channel(member->session);
@@ -544,6 +552,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "add-member");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Size", "%u", conference->count);
switch_event_fire(&event);
}
}
@@ -641,6 +650,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", "%s", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "del-member");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Size", "%u", conference->count);
switch_event_fire(&event);
}
}
@@ -689,7 +699,9 @@
int has_file_data = 0;
if (conference->perpetual_sound && !conference->fnode) {
- conference_play_file(conference, conference->perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 0);
+ conference_play_file(conference, conference->perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1);
+ } else if (conference->moh_sound && conference->count == 1 && !conference->fnode) {
+ conference_play_file(conference, conference->moh_sound, CONF_DEFAULT_LEADIN, NULL, 1);
}
/* Sync the conference to a single timing source */
@@ -1938,6 +1950,11 @@
conference->async_fnode->done++;
count++;
}
+ } else if (stop == FILE_STOP_ASYNC) {
+ if (conference->async_fnode) {
+ conference->async_fnode->done++;
+ count++;
+ }
} else {
if (conference->fnode) {
conference->fnode->done++;
@@ -4546,6 +4563,7 @@
char *caller_controls = NULL;
char *member_flags = NULL;
char *perpetual_sound = NULL;
+ char *moh_sound = NULL;
uint32_t max_members = 0;
uint32_t anounce_count = 0;
char *maxmember_sound = NULL;
@@ -4595,6 +4613,8 @@
alone_sound = val;
} else if (!strcasecmp(var, "perpetual-sound")) {
perpetual_sound = val;
+ } else if (!strcasecmp(var, "moh-sound")) {
+ moh_sound = val;
} else if (!strcasecmp(var, "ack-sound")) {
ack_sound = val;
} else if (!strcasecmp(var, "nack-sound")) {
@@ -4716,6 +4736,10 @@
conference->mflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
}
+ if (!switch_strlen_zero(moh_sound)) {
+ conference->moh_sound = switch_core_strdup(conference->pool, moh_sound);
+ }
+
if (member_flags) {
set_mflags(member_flags, &conference->mflags);
}
1
0