Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d66839de
提交
d66839de
authored
4月 02, 2015
作者:
karl anderson
提交者:
Luis Azedo
7月 03, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7774 add mod_kazoo
#resolve
上级
0244af22
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
4664 行增加
和
0 行删除
+4664
-0
modules.conf.in
build/modules.conf.in
+1
-0
configure.ac
configure.ac
+1
-0
Makefile.am
src/mod/event_handlers/mod_kazoo/Makefile.am
+7
-0
kazoo.conf.xml
...t_handlers/mod_kazoo/conf/autoload_configs/kazoo.conf.xml
+215
-0
kazoo_commands.c
src/mod/event_handlers/mod_kazoo/kazoo_commands.c
+152
-0
kazoo_dptools.c
src/mod/event_handlers/mod_kazoo/kazoo_dptools.c
+182
-0
kazoo_event_stream.c
src/mod/event_handlers/mod_kazoo/kazoo_event_stream.c
+584
-0
kazoo_fetch_agent.c
src/mod/event_handlers/mod_kazoo/kazoo_fetch_agent.c
+707
-0
kazoo_node.c
src/mod/event_handlers/mod_kazoo/kazoo_node.c
+1254
-0
kazoo_utils.c
src/mod/event_handlers/mod_kazoo/kazoo_utils.c
+614
-0
mod_kazoo.c
src/mod/event_handlers/mod_kazoo/mod_kazoo.c
+776
-0
mod_kazoo.h
src/mod/event_handlers/mod_kazoo/mod_kazoo.h
+171
-0
没有找到文件。
build/modules.conf.in
浏览文件 @
d66839de
...
...
@@ -105,6 +105,7 @@ event_handlers/mod_event_socket
#event_handlers/mod_json_cdr
#event_handlers/mod_radius_cdr
#event_handlers/mod_odbc_cdr
#event_handlers/mod_kazoo
#event_handlers/mod_rayo
#event_handlers/mod_smpp
#event_handlers/mod_snmp
...
...
configure.ac
浏览文件 @
d66839de
...
...
@@ -1772,6 +1772,7 @@ AC_CONFIG_FILES([Makefile
src/mod/event_handlers/mod_event_test/Makefile
src/mod/event_handlers/mod_format_cdr/Makefile
src/mod/event_handlers/mod_json_cdr/Makefile
src/mod/event_handlers/mod_kazoo/Makefile
src/mod/event_handlers/mod_radius_cdr/Makefile
src/mod/event_handlers/mod_odbc_cdr/Makefile
src/mod/event_handlers/mod_rayo/Makefile
...
...
src/mod/event_handlers/mod_kazoo/Makefile.am
0 → 100644
浏览文件 @
d66839de
include
$(top_srcdir)/build/modmake.rulesam
MODNAME
=
mod_kazoo
mod_LTLIBRARIES
=
mod_kazoo.la
mod_kazoo_la_SOURCES
=
mod_kazoo.c kazoo_utils.c kazoo_node.c kazoo_event_stream.c kazoo_fetch_agent.c kazoo_commands.c kazoo_dptools.c
mod_kazoo_la_CFLAGS
=
$(AM_CFLAGS)
@ERLANG_CFLAGS@
-D_REENTRANT
mod_kazoo_la_LIBADD
=
$(switch_builddir)
/libfreeswitch.la
mod_kazoo_la_LDFLAGS
=
-avoid-version
-module
-no-undefined
-shared
@ERLANG_LDFLAGS@
src/mod/event_handlers/mod_kazoo/conf/autoload_configs/kazoo.conf.xml
0 → 100644
浏览文件 @
d66839de
<?xml version="1.0" encoding="UTF-8"?>
<configuration
name=
"kazoo.conf"
description=
"General purpose Erlang c-node produced to better fit the Kazoo project"
>
<settings>
<param
name=
"listen-ip"
value=
"0.0.0.0"
/>
<param
name=
"listen-port"
value=
"8031"
/>
<!--<param name="cookie-file" value="/etc/freeswitch/autoload_configs/.erlang.cookie" />-->
<param
name=
"cookie"
value=
"change_me"
/>
<param
name=
"shortname"
value=
"false"
/>
<param
name=
"nodename"
value=
"freeswitch"
/>
<param
name=
"send-msg-batch-size"
value=
"10"
/>
<param
name=
"receive-timeout"
value=
"1"
/>
<!--<param name="receive-msg-preallocate" value="0" />-->
<!--<param name="event-stream-preallocate" value="0" />-->
<!--<param name="event-stream-framing" value="2" />-->
<!--<param name="kazoo-var-prefix" value="ecallmgr" />-->
<!--<param name="compat-rel" value="12"/> -->
</settings>
<event-filter
type=
"whitelist"
>
<header
name=
"Acquired-UUID"
/>
<header
name=
"action"
/>
<header
name=
"Action"
/>
<header
name=
"alt_event_type"
/>
<header
name=
"Answer-State"
/>
<header
name=
"Application"
/>
<header
name=
"Application-Data"
/>
<header
name=
"Application-Name"
/>
<header
name=
"Application-Response"
/>
<header
name=
"att_xfer_replaced_by"
/>
<header
name=
"Auth-Method"
/>
<header
name=
"Auth-Realm"
/>
<header
name=
"Auth-User"
/>
<header
name=
"Bridge-A-Unique-ID"
/>
<header
name=
"Bridge-B-Unique-ID"
/>
<header
name=
"Call-Direction"
/>
<header
name=
"Caller-Callee-ID-Name"
/>
<header
name=
"Caller-Callee-ID-Number"
/>
<header
name=
"Caller-Caller-ID-Name"
/>
<header
name=
"Caller-Caller-ID-Number"
/>
<header
name=
"Caller-Context"
/>
<header
name=
"Caller-Controls"
/>
<header
name=
"Caller-Destination-Number"
/>
<header
name=
"Caller-Dialplan"
/>
<header
name=
"Caller-Network-Addr"
/>
<header
name=
"Caller-Unique-ID"
/>
<header
name=
"Call-ID"
/>
<header
name=
"Channel-Call-State"
/>
<header
name=
"Channel-Call-UUID"
/>
<header
name=
"Channel-Presence-ID"
/>
<header
name=
"Channel-State"
/>
<header
name=
"Chat-Permissions"
/>
<header
name=
"Conference-Name"
/>
<header
name=
"Conference-Profile-Name"
/>
<header
name=
"Conference-Unique-ID"
/>
<header
name=
"Conference-Size"
/>
<header
name=
"New-ID"
/>
<header
name=
"Old-ID"
/>
<header
name=
"Detected-Tone"
/>
<header
name=
"dialog_state"
/>
<header
name=
"direction"
/>
<header
name=
"Distributed-From"
/>
<header
name=
"DTMF-Digit"
/>
<header
name=
"DTMF-Duration"
/>
<header
name=
"Event-Date-Timestamp"
/>
<header
name=
"Event-Name"
/>
<header
name=
"Event-Subclass"
/>
<header
name=
"Expires"
/>
<header
name=
"Ext-SIP-IP"
/>
<header
name=
"File"
/>
<header
name=
"FreeSWITCH-Hostname"
/>
<header
name=
"from"
/>
<header
name=
"Hunt-Destination-Number"
/>
<header
name=
"ip"
/>
<header
name=
"Message-Account"
/>
<header
name=
"metadata"
/>
<header
name=
"old_node_channel_uuid"
/>
<header
name=
"Other-Leg-Callee-ID-Name"
/>
<header
name=
"Other-Leg-Callee-ID-Number"
/>
<header
name=
"Other-Leg-Caller-ID-Name"
/>
<header
name=
"Other-Leg-Caller-ID-Number"
/>
<header
name=
"Other-Leg-Destination-Number"
/>
<header
name=
"Other-Leg-Direction"
/>
<header
name=
"Other-Leg-Unique-ID"
/>
<header
name=
"Participant-Type"
/>
<header
name=
"Path"
/>
<header
name=
"profile_name"
/>
<header
name=
"Profiles"
/>
<header
name=
"proto-specific-event-name"
/>
<header
name=
"Raw-Application-Data"
/>
<header
name=
"Resigning-UUID"
/>
<header
name=
"set"
/>
<header
name=
"sip_auto_answer"
/>
<header
name=
"sip_auth_method"
/>
<header
name=
"sip_from_host"
/>
<header
name=
"sip_from_user"
/>
<header
name=
"sip_to_host"
/>
<header
name=
"sip_to_user"
/>
<header
name=
"sub-call-id"
/>
<header
name=
"technology"
/>
<header
name=
"to"
/>
<header
name=
"Unique-ID"
/>
<header
name=
"URL"
/>
<header
name=
"variable_channel_is_moving"
/>
<header
name=
"variable_collected_digits"
/>
<header
name=
"variable_current_application"
/>
<header
name=
"variable_current_application_data"
/>
<header
name=
"variable_domain_name"
/>
<header
name=
"variable_effective_caller_id_name"
/>
<header
name=
"variable_effective_caller_id_number"
/>
<header
name=
"variable_fax_bad_rows"
/>
<header
name=
"variable_fax_document_total_pages"
/>
<header
name=
"variable_fax_document_transferred_pages"
/>
<header
name=
"variable_fax_ecm_used"
/>
<header
name=
"variable_fax_result_code"
/>
<header
name=
"variable_fax_result_text"
/>
<header
name=
"variable_fax_success"
/>
<header
name=
"variable_fax_transfer_rate"
/>
<header
name=
"variable_holding_uuid"
/>
<header
name=
"variable_hold_music"
/>
<header
name=
"variable_media_group_id"
/>
<header
name=
"variable_originate_disposition"
/>
<header
name=
"variable_playback_terminator_used"
/>
<header
name=
"variable_presence_id"
/>
<header
name=
"variable_record_ms"
/>
<header
name=
"variable_recovered"
/>
<header
name=
"variable_silence_hits_exhausted"
/>
<header
name=
"variable_sip_auth_realm"
/>
<header
name=
"variable_sip_from_host"
/>
<header
name=
"variable_sip_from_user"
/>
<header
name=
"variable_sip_h_X-AUTH-IP"
/>
<header
name=
"variable_sip_received_ip"
/>
<header
name=
"variable_sip_to_host"
/>
<header
name=
"variable_sip_to_user"
/>
<header
name=
"variable_sofia_profile_name"
/>
<header
name=
"variable_transfer_history"
/>
<header
name=
"variable_user_name"
/>
<header
name=
"variable_endpoint_disposition"
/>
<header
name=
"variable_originate_disposition"
/>
<header
name=
"variable_bridge_hangup_cause"
/>
<header
name=
"variable_hangup_cause"
/>
<header
name=
"variable_last_bridge_proto_specific_hangup_cause"
/>
<header
name=
"variable_proto_specific_hangup_cause"
/>
<header
name=
"VM-Call-ID"
/>
<header
name=
"VM-sub-call-id"
/>
<header
name=
"whistle_application_name"
/>
<header
name=
"whistle_application_response"
/>
<header
name=
"whistle_event_name"
/>
<header
name=
"sip_auto_answer_notify"
/>
<header
name=
"eavesdrop_group"
/>
<header
name=
"origination_caller_id_name"
/>
<header
name=
"origination_caller_id_number"
/>
<header
name=
"origination_callee_id_name"
/>
<header
name=
"origination_callee_id_number"
/>
<header
name=
"sip_auth_username"
/>
<header
name=
"sip_auth_password"
/>
<header
name=
"effective_caller_id_name"
/>
<header
name=
"effective_caller_id_number"
/>
<header
name=
"effective_callee_id_name"
/>
<header
name=
"effective_callee_id_number"
/>
<!-- Registrations -->
<header
name=
"call-id"
/>
<header
name=
"profile-name"
/>
<header
name=
"from-user"
/>
<header
name=
"from-host"
/>
<header
name=
"presence-hosts"
/>
<header
name=
"contact"
/>
<header
name=
"rpid"
/>
<header
name=
"status"
/>
<header
name=
"expires"
/>
<header
name=
"to-user"
/>
<header
name=
"to-host"
/>
<header
name=
"network-ip"
/>
<header
name=
"network-port"
/>
<header
name=
"username"
/>
<header
name=
"realm"
/>
<header
name=
"user-agent"
/>
<!-- CDR Headers -->
<header
name=
"Hangup-Cause"
/>
<header
name=
"Unique-ID"
/>
<header
name=
"variable_switch_r_sdp"
/>
<header
name=
"variable_sip_local_sdp_str"
/>
<header
name=
"variable_sip_to_uri"
/>
<header
name=
"variable_sip_from_uri"
/>
<header
name=
"variable_effective_caller_id_number"
/>
<header
name=
"Caller-Caller-ID-Number"
/>
<header
name=
"variable_effective_caller_id_name"
/>
<header
name=
"Caller-Caller-ID-Name"
/>
<header
name=
"Caller-Callee-ID-Name"
/>
<header
name=
"Caller-Callee-ID-Number"
/>
<header
name=
"Other-Leg-Unique-ID"
/>
<header
name=
"variable_sip_user_agent"
/>
<header
name=
"variable_duration"
/>
<header
name=
"variable_billsec"
/>
<header
name=
"variable_progresssec"
/>
<header
name=
"variable_progress_uepoch"
/>
<header
name=
"variable_progress_media_uepoch"
/>
<header
name=
"variable_start_uepoch"
/>
<header
name=
"variable_digits_dialed"
/>
<header
name=
"variable_sip_cid_type"
/>
<!-- Conference Headers -->
<header
name=
"Hear"
/>
<header
name=
"Speak"
/>
<header
name=
"Video"
/>
<header
name=
"Talking"
/>
<header
name=
"Mute-Detect"
/>
<header
name=
"Member-ID"
/>
<header
name=
"Member-Type"
/>
<header
name=
"Energy-Level"
/>
<header
name=
"Current-Energy"
/>
<header
name=
"Floor"
/>
</event-filter>
</configuration>
src/mod/event_handlers/mod_kazoo/kazoo_commands.c
0 → 100644
浏览文件 @
d66839de
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@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@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Karl Anderson <karl@2600hz.com>
* Darren Schreiber <darren@2600hz.com>
*
*
* kazoo_commands.c -- clones of mod_commands commands slightly modified for kazoo
*
*/
#include "mod_kazoo.h"
#define UUID_SET_DESC "Set a variable"
#define UUID_SET_SYNTAX "<uuid> <var> [value]"
#define UUID_MULTISET_DESC "Set multiple variables"
#define UUID_MULTISET_SYNTAX "<uuid> <var>=<value>;<var>=<value>..."
SWITCH_STANDARD_API
(
uuid_setvar_function
)
{
switch_core_session_t
*
psession
=
NULL
;
char
*
mycmd
=
NULL
,
*
argv
[
3
]
=
{
0
};
int
argc
=
0
;
if
(
!
zstr
(
cmd
)
&&
(
mycmd
=
strdup
(
cmd
)))
{
argc
=
switch_separate_string
(
mycmd
,
' '
,
argv
,
(
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])));
if
((
argc
==
2
||
argc
==
3
)
&&
!
zstr
(
argv
[
0
]))
{
char
*
uuid
=
argv
[
0
];
char
*
var_name
=
argv
[
1
];
char
*
var_value
=
NULL
;
if
(
argc
==
3
)
{
var_value
=
argv
[
2
];
}
if
((
psession
=
switch_core_session_locate
(
uuid
)))
{
switch_channel_t
*
channel
;
switch_event_t
*
event
;
channel
=
switch_core_session_get_channel
(
psession
);
if
(
zstr
(
var_name
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"No variable name specified.
\n
"
);
stream
->
write_function
(
stream
,
"-ERR No variable specified
\n
"
);
}
else
{
switch_channel_set_variable
(
channel
,
var_name
,
var_value
);
stream
->
write_function
(
stream
,
"+OK
\n
"
);
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_CHANNEL_DATA
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
channel
,
event
);
switch_event_fire
(
&
event
);
}
switch_core_session_rwunlock
(
psession
);
}
else
{
stream
->
write_function
(
stream
,
"-ERR No such channel!
\n
"
);
}
goto
done
;
}
}
stream
->
write_function
(
stream
,
"-USAGE: %s
\n
"
,
UUID_SET_SYNTAX
);
done
:
switch_safe_free
(
mycmd
);
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_STANDARD_API
(
uuid_setvar_multi_function
)
{
switch_core_session_t
*
psession
=
NULL
;
char
*
mycmd
=
NULL
,
*
vars
,
*
argv
[
64
]
=
{
0
};
int
argc
=
0
;
char
*
var_name
,
*
var_value
=
NULL
;
if
(
!
zstr
(
cmd
)
&&
(
mycmd
=
strdup
(
cmd
)))
{
char
*
uuid
=
mycmd
;
if
(
!
(
vars
=
strchr
(
uuid
,
' '
)))
{
goto
done
;
}
*
vars
++
=
'\0'
;
if
((
psession
=
switch_core_session_locate
(
uuid
)))
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
psession
);
switch_event_t
*
event
;
int
x
,
y
=
0
;
argc
=
switch_separate_string
(
vars
,
';'
,
argv
,
(
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])));
for
(
x
=
0
;
x
<
argc
;
x
++
)
{
var_name
=
argv
[
x
];
if
(
var_name
&&
(
var_value
=
strchr
(
var_name
,
'='
)))
{
*
var_value
++
=
'\0'
;
}
if
(
zstr
(
var_name
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"No variable name specified.
\n
"
);
stream
->
write_function
(
stream
,
"-ERR No variable specified
\n
"
);
}
else
{
switch_channel_set_variable
(
channel
,
var_name
,
var_value
);
y
++
;
}
}
/* keep kazoo nodes in sync */
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_CHANNEL_DATA
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
channel
,
event
);
switch_event_fire
(
&
event
);
}
switch_core_session_rwunlock
(
psession
);
if
(
y
)
{
stream
->
write_function
(
stream
,
"+OK
\n
"
);
goto
done
;
}
}
else
{
stream
->
write_function
(
stream
,
"-ERR No such channel!
\n
"
);
}
}
stream
->
write_function
(
stream
,
"-USAGE: %s
\n
"
,
UUID_MULTISET_SYNTAX
);
done
:
switch_safe_free
(
mycmd
);
return
SWITCH_STATUS_SUCCESS
;
}
void
add_kz_commands
(
switch_loadable_module_interface_t
**
module_interface
,
switch_api_interface_t
*
api_interface
)
{
SWITCH_ADD_API
(
api_interface
,
"kz_uuid_setvar_multi"
,
UUID_SET_DESC
,
uuid_setvar_multi_function
,
UUID_MULTISET_SYNTAX
);
switch_console_set_complete
(
"add kz_uuid_setvar_multi ::console::list_uuid"
);
SWITCH_ADD_API
(
api_interface
,
"kz_uuid_setvar"
,
UUID_MULTISET_DESC
,
uuid_setvar_function
,
UUID_SET_SYNTAX
);
switch_console_set_complete
(
"add kz_uuid_setvar ::console::list_uuid"
);
}
src/mod/event_handlers/mod_kazoo/kazoo_dptools.c
0 → 100644
浏览文件 @
d66839de
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@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@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Karl Anderson <karl@2600hz.com>
* Darren Schreiber <darren@2600hz.com>
*
*
* kazoo_dptools.c -- clones of mod_dptools commands slightly modified for kazoo
*
*/
#include "mod_kazoo.h"
#define SET_SHORT_DESC "Set a channel variable"
#define SET_LONG_DESC "Set a channel variable for the channel calling the application."
#define SET_SYNTAX "<varname>=<value>"
#define MULTISET_SHORT_DESC "Set many channel variables"
#define MULTISET_LONG_DESC "Set many channel variables for the channel calling the application"
#define MULTISET_SYNTAX "[^^<delim>]<varname>=<value> <var2>=<val2>"
#define UNSET_SHORT_DESC "Unset a channel variable"
#define UNSET_LONG_DESC "Unset a channel variable for the channel calling the application."
#define UNSET_SYNTAX "<varname>"
#define MULTIUNSET_SHORT_DESC "Unset many channel variables"
#define MULTIUNSET_LONG_DESC "Unset many channel variables for the channel calling the application."
#define MULTIUNSET_SYNTAX "[^^<delim>]<varname> <var2> <var3>"
static
void
base_set
(
switch_core_session_t
*
session
,
const
char
*
data
,
switch_stack_t
stack
)
{
char
*
var
,
*
val
=
NULL
;
if
(
zstr
(
data
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"No variable name specified.
\n
"
);
}
else
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
char
*
expanded
=
NULL
;
var
=
switch_core_session_strdup
(
session
,
data
);
if
(
!
(
val
=
strchr
(
var
,
'='
)))
{
val
=
strchr
(
var
,
','
);
}
if
(
val
)
{
*
val
++
=
'\0'
;
if
(
zstr
(
val
))
{
val
=
NULL
;
}
}
if
(
val
)
{
expanded
=
switch_channel_expand_variables
(
channel
,
val
);
}
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"%s SET [%s]=[%s]
\n
"
,
switch_channel_get_name
(
channel
),
var
,
expanded
?
expanded
:
"UNDEF"
);
switch_channel_add_variable_var_check
(
channel
,
var
,
expanded
,
SWITCH_FALSE
,
stack
);
if
(
expanded
&&
expanded
!=
val
)
{
switch_safe_free
(
expanded
);
}
}
}
SWITCH_STANDARD_APP
(
multiset_function
)
{
char
delim
=
' '
;
char
*
arg
=
(
char
*
)
data
;
switch_event_t
*
event
;
if
(
!
zstr
(
arg
)
&&
*
arg
==
'^'
&&
*
(
arg
+
1
)
==
'^'
)
{
arg
+=
2
;
delim
=
*
arg
++
;
}
if
(
arg
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
char
*
array
[
256
]
=
{
0
};
int
i
,
argc
;
arg
=
switch_core_session_strdup
(
session
,
arg
);
argc
=
switch_split
(
arg
,
delim
,
array
);
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
base_set
(
session
,
array
[
i
],
SWITCH_STACK_BOTTOM
);
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_CHANNEL_DATA
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
channel
,
event
);
switch_event_fire
(
&
event
);
}
}
else
{
base_set
(
session
,
data
,
SWITCH_STACK_BOTTOM
);
}
}
SWITCH_STANDARD_APP
(
set_function
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_event_t
*
event
;
base_set
(
session
,
data
,
SWITCH_STACK_BOTTOM
);
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_CHANNEL_DATA
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
channel
,
event
);
switch_event_fire
(
&
event
);
}
}
SWITCH_STANDARD_APP
(
unset_function
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_event_t
*
event
;
if
(
zstr
(
data
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"No variable name specified.
\n
"
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"UNSET [%s]
\n
"
,
(
char
*
)
data
);
switch_channel_set_variable
(
switch_core_session_get_channel
(
session
),
data
,
NULL
);
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_CHANNEL_DATA
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
channel
,
event
);
switch_event_fire
(
&
event
);
}
}
SWITCH_STANDARD_APP
(
multiunset_function
)
{
char
delim
=
' '
;
char
*
arg
=
(
char
*
)
data
;
if
(
!
zstr
(
arg
)
&&
*
arg
==
'^'
&&
*
(
arg
+
1
)
==
'^'
)
{
arg
+=
2
;
delim
=
*
arg
++
;
}
if
(
arg
)
{
char
*
array
[
256
]
=
{
0
};
int
i
,
argc
;
arg
=
switch_core_session_strdup
(
session
,
arg
);
argc
=
switch_split
(
arg
,
delim
,
array
);
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
switch_channel_set_variable
(
switch_core_session_get_channel
(
session
),
array
[
i
],
NULL
);
}
}
else
{
switch_channel_set_variable
(
switch_core_session_get_channel
(
session
),
arg
,
NULL
);
}
}
void
add_kz_dptools
(
switch_loadable_module_interface_t
**
module_interface
,
switch_application_interface_t
*
app_interface
)
{
SWITCH_ADD_APP
(
app_interface
,
"kz_set"
,
SET_SHORT_DESC
,
SET_LONG_DESC
,
set_function
,
SET_SYNTAX
,
SAF_SUPPORT_NOMEDIA
|
SAF_ROUTING_EXEC
|
SAF_ZOMBIE_EXEC
);
SWITCH_ADD_APP
(
app_interface
,
"kz_multiset"
,
MULTISET_SHORT_DESC
,
MULTISET_LONG_DESC
,
multiset_function
,
MULTISET_SYNTAX
,
SAF_SUPPORT_NOMEDIA
|
SAF_ROUTING_EXEC
|
SAF_ZOMBIE_EXEC
);
SWITCH_ADD_APP
(
app_interface
,
"kz_unset"
,
UNSET_SHORT_DESC
,
UNSET_LONG_DESC
,
unset_function
,
UNSET_SYNTAX
,
SAF_SUPPORT_NOMEDIA
|
SAF_ROUTING_EXEC
|
SAF_ZOMBIE_EXEC
);
SWITCH_ADD_APP
(
app_interface
,
"kz_multiunset"
,
MULTISET_SHORT_DESC
,
MULTISET_LONG_DESC
,
multiunset_function
,
MULTIUNSET_SYNTAX
,
SAF_SUPPORT_NOMEDIA
|
SAF_ROUTING_EXEC
|
SAF_ZOMBIE_EXEC
);
}
src/mod/event_handlers/mod_kazoo/kazoo_event_stream.c
0 → 100644
浏览文件 @
d66839de
差异被折叠。
点击展开。
src/mod/event_handlers/mod_kazoo/kazoo_fetch_agent.c
0 → 100644
浏览文件 @
d66839de
差异被折叠。
点击展开。
src/mod/event_handlers/mod_kazoo/kazoo_node.c
0 → 100644
浏览文件 @
d66839de
差异被折叠。
点击展开。
src/mod/event_handlers/mod_kazoo/kazoo_utils.c
0 → 100644
浏览文件 @
d66839de
差异被折叠。
点击展开。
src/mod/event_handlers/mod_kazoo/mod_kazoo.c
0 → 100644
浏览文件 @
d66839de
差异被折叠。
点击展开。
src/mod/event_handlers/mod_kazoo/mod_kazoo.h
0 → 100644
浏览文件 @
d66839de
#include <switch.h>
#include <ei.h>
#define MAX_ACL 100
#define CMD_BUFLEN 1024 * 1000
#define MAX_QUEUE_LEN 25000
#define MAX_MISSED 500
#define MAX_PID_CHARS 255
#define VERSION "mod_kazoo v1.2.10-14"
#define API_COMMAND_DISCONNECT 0
#define API_COMMAND_REMOTE_IP 1
#define API_COMMAND_STREAMS 2
#define API_COMMAND_BINDINGS 3
typedef
enum
{
LFLAG_RUNNING
=
(
1
<<
0
)
}
event_flag_t
;
struct
ei_send_msg_s
{
ei_x_buff
buf
;
erlang_pid
pid
;
};
typedef
struct
ei_send_msg_s
ei_send_msg_t
;
struct
ei_received_msg_s
{
ei_x_buff
buf
;
erlang_msg
msg
;
};
typedef
struct
ei_received_msg_s
ei_received_msg_t
;
struct
ei_event_binding_s
{
char
id
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
];
switch_event_node_t
*
node
;
switch_event_types_t
type
;
const
char
*
subclass_name
;
struct
ei_event_binding_s
*
next
;
};
typedef
struct
ei_event_binding_s
ei_event_binding_t
;
struct
ei_event_stream_s
{
switch_memory_pool_t
*
pool
;
ei_event_binding_t
*
bindings
;
switch_queue_t
*
queue
;
switch_socket_t
*
acceptor
;
switch_pollset_t
*
pollset
;
switch_pollfd_t
*
pollfd
;
switch_socket_t
*
socket
;
switch_mutex_t
*
socket_mutex
;
switch_bool_t
connected
;
char
remote_ip
[
25
];
uint16_t
remote_port
;
char
local_ip
[
25
];
uint16_t
local_port
;
erlang_pid
pid
;
uint32_t
flags
;
struct
ei_event_stream_s
*
next
;
};
typedef
struct
ei_event_stream_s
ei_event_stream_t
;
struct
ei_node_s
{
int
nodefd
;
switch_atomic_t
pending_bgapi
;
switch_atomic_t
receive_handlers
;
switch_memory_pool_t
*
pool
;
ei_event_stream_t
*
event_streams
;
switch_mutex_t
*
event_streams_mutex
;
switch_queue_t
*
send_msgs
;
switch_queue_t
*
received_msgs
;
char
*
peer_nodename
;
switch_time_t
created_time
;
switch_socket_t
*
socket
;
char
remote_ip
[
25
];
uint16_t
remote_port
;
char
local_ip
[
25
];
uint16_t
local_port
;
uint32_t
flags
;
struct
ei_node_s
*
next
;
};
typedef
struct
ei_node_s
ei_node_t
;
struct
globals_s
{
switch_memory_pool_t
*
pool
;
switch_atomic_t
threads
;
switch_socket_t
*
acceptor
;
struct
ei_cnode_s
ei_cnode
;
switch_thread_rwlock_t
*
ei_nodes_lock
;
ei_node_t
*
ei_nodes
;
switch_xml_binding_t
*
config_fetch_binding
;
switch_xml_binding_t
*
directory_fetch_binding
;
switch_xml_binding_t
*
dialplan_fetch_binding
;
switch_xml_binding_t
*
chatplan_fetch_binding
;
switch_xml_binding_t
*
channels_fetch_binding
;
switch_hash_t
*
event_filter
;
int
epmdfd
;
int
num_worker_threads
;
switch_bool_t
nat_map
;
switch_bool_t
ei_shortname
;
int
ei_compat_rel
;
char
*
ip
;
char
*
ei_cookie
;
char
*
ei_nodename
;
char
*
kazoo_var_prefix
;
int
var_prefix_length
;
uint32_t
flags
;
int
send_all_headers
;
int
send_all_private_headers
;
int
connection_timeout
;
int
receive_timeout
;
int
receive_msg_preallocate
;
int
event_stream_preallocate
;
int
send_msg_batch
;
short
event_stream_framing
;
}
globals
;
typedef
struct
globals_s
globals_t
;
/* kazoo_node.c */
switch_status_t
new_kazoo_node
(
int
nodefd
,
ErlConnect
*
conn
);
/* kazoo_event_stream.c */
ei_event_stream_t
*
find_event_stream
(
ei_event_stream_t
*
event_streams
,
const
erlang_pid
*
from
);
ei_event_stream_t
*
new_event_stream
(
ei_event_stream_t
**
event_streams
,
const
erlang_pid
*
from
);
switch_status_t
remove_event_stream
(
ei_event_stream_t
**
event_streams
,
const
erlang_pid
*
from
);
switch_status_t
remove_event_streams
(
ei_event_stream_t
**
event_streams
);
unsigned
long
get_stream_port
(
const
ei_event_stream_t
*
event_stream
);
switch_status_t
add_event_binding
(
ei_event_stream_t
*
event_stream
,
const
switch_event_types_t
event_type
,
const
char
*
subclass_name
);
switch_status_t
remove_event_binding
(
ei_event_stream_t
*
event_stream
,
const
switch_event_types_t
event_type
,
const
char
*
subclass_name
);
switch_status_t
remove_event_bindings
(
ei_event_stream_t
*
event_stream
);
/* kazoo_fetch_agent.c */
switch_status_t
bind_fetch_agents
();
switch_status_t
unbind_fetch_agents
();
switch_status_t
remove_xml_clients
(
ei_node_t
*
ei_node
);
switch_status_t
add_fetch_handler
(
ei_node_t
*
ei_node
,
erlang_pid
*
from
,
switch_xml_binding_t
*
binding
);
switch_status_t
remove_fetch_handlers
(
ei_node_t
*
ei_node
,
erlang_pid
*
from
);
switch_status_t
fetch_reply
(
char
*
uuid_str
,
char
*
xml_str
,
switch_xml_binding_t
*
binding
);
switch_status_t
handle_api_command_streams
(
ei_node_t
*
ei_node
,
switch_stream_handle_t
*
stream
);
/* kazoo_utils.c */
void
close_socket
(
switch_socket_t
**
sock
);
void
close_socketfd
(
int
*
sockfd
);
switch_socket_t
*
create_socket
(
switch_memory_pool_t
*
pool
);
switch_status_t
create_ei_cnode
(
const
char
*
ip_addr
,
const
char
*
name
,
struct
ei_cnode_s
*
ei_cnode
);
switch_status_t
ei_compare_pids
(
const
erlang_pid
*
pid1
,
const
erlang_pid
*
pid2
);
void
ei_encode_switch_event_headers
(
ei_x_buff
*
ebuf
,
switch_event_t
*
event
);
void
ei_link
(
ei_node_t
*
ei_node
,
erlang_pid
*
from
,
erlang_pid
*
to
);
void
ei_encode_switch_event
(
ei_x_buff
*
ebuf
,
switch_event_t
*
event
);
int
ei_helper_send
(
ei_node_t
*
ei_node
,
erlang_pid
*
to
,
ei_x_buff
*
buf
);
int
ei_decode_atom_safe
(
char
*
buf
,
int
*
index
,
char
*
dst
);
int
ei_decode_string_or_binary_limited
(
char
*
buf
,
int
*
index
,
int
maxsize
,
char
*
dst
);
int
ei_decode_string_or_binary
(
char
*
buf
,
int
*
index
,
char
**
dst
);
switch_hash_t
*
create_default_filter
();
/* kazoo_commands.c */
void
add_kz_commands
(
switch_loadable_module_interface_t
**
module_interface
,
switch_api_interface_t
*
api_interface
);
/* kazoo_dptools.c */
void
add_kz_dptools
(
switch_loadable_module_interface_t
**
module_interface
,
switch_application_interface_t
*
app_interface
);
#define _ei_x_encode_string(buf, string) { ei_x_encode_binary(buf, string, strlen(string)); }
/* 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:
*/
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论