Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c06e3d76
提交
c06e3d76
authored
7月 30, 2012
作者:
David Yat Sin
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'nsg-4.3' of
ssh://git.sangoma.com/smg_freeswitch
into nsg-4.3
上级
3c8d14a2
0c87442d
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
885 行增加
和
1031 行删除
+885
-1031
tdm.c
libs/freetdm/mod_freetdm/tdm.c
+7
-5
media_gateway.c
src/mod/endpoints/mod_media_gateway/media_gateway.c
+36
-6
media_gateway_cmd_handler.c
...d/endpoints/mod_media_gateway/media_gateway_cmd_handler.c
+14
-7
media_gateway_stack.h
src/mod/endpoints/mod_media_gateway/media_gateway_stack.h
+3
-3
media_gateway_utils.c
src/mod/endpoints/mod_media_gateway/media_gateway_utils.c
+9
-3
media_gateway_xml.c
src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
+98
-58
mod_media_gateway.c
src/mod/endpoints/mod_media_gateway/mod_media_gateway.c
+9
-22
mod_media_gateway.h
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h
+6
-2
mod_opal.cpp
src/mod/endpoints/mod_opal/mod_opal.cpp
+518
-776
mod_opal.h
src/mod/endpoints/mod_opal/mod_opal.h
+185
-149
没有找到文件。
libs/freetdm/mod_freetdm/tdm.c
浏览文件 @
c06e3d76
...
@@ -84,7 +84,7 @@ switch_io_routines_t ctdm_io_routines = {
...
@@ -84,7 +84,7 @@ switch_io_routines_t ctdm_io_routines = {
.
receive_message
=
channel_receive_message
.
receive_message
=
channel_receive_message
};
};
static
void
ctdm_report_alarms
(
ftdm_channel_t
*
channel
,
const
char
*
mg_profile_name
)
static
void
ctdm_report_alarms
(
ftdm_channel_t
*
channel
)
{
{
switch_event_t
*
event
=
NULL
;
switch_event_t
*
event
=
NULL
;
ftdm_alarm_flag_t
alarmflag
=
0
;
ftdm_alarm_flag_t
alarmflag
=
0
;
...
@@ -109,8 +109,6 @@ static void ctdm_report_alarms(ftdm_channel_t *channel, const char* mg_profile_n
...
@@ -109,8 +109,6 @@ static void ctdm_report_alarms(ftdm_channel_t *channel, const char* mg_profile_n
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"condition"
,
"ftdm-alarm-trap"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"condition"
,
"ftdm-alarm-trap"
);
}
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"mg-profile-name"
,
mg_profile_name
);
if
(
alarmflag
&
FTDM_ALARM_RED
)
{
if
(
alarmflag
&
FTDM_ALARM_RED
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alarm"
,
"red"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alarm"
,
"red"
);
}
}
...
@@ -130,6 +128,8 @@ static void ctdm_report_alarms(ftdm_channel_t *channel, const char* mg_profile_n
...
@@ -130,6 +128,8 @@ static void ctdm_report_alarms(ftdm_channel_t *channel, const char* mg_profile_n
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alarm"
,
"general"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alarm"
,
"general"
);
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Reporting [%s] alarms for %s:%d
\n
"
,
(
alarmflag
?
"ftdm-alarm-clear"
:
"ftdm-alarm-trap"
),
ftdm_channel_get_span_name
(
channel
),
ftdm_channel_get_id
(
channel
));
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
return
;
return
;
...
@@ -149,7 +149,6 @@ static void ctdm_event_handler(switch_event_t *event)
...
@@ -149,7 +149,6 @@ static void ctdm_event_handler(switch_event_t *event)
const
char
*
chan_number
=
NULL
;
const
char
*
chan_number
=
NULL
;
uint32_t
chan_id
=
0
;
uint32_t
chan_id
=
0
;
const
char
*
cond
=
switch_event_get_header
(
event
,
"condition"
);
const
char
*
cond
=
switch_event_get_header
(
event
,
"condition"
);
const
char
*
mg_profile_name
=
switch_event_get_header
(
event
,
"mg-profile-name"
);
if
(
zstr
(
cond
))
{
if
(
zstr
(
cond
))
{
return
;
return
;
...
@@ -187,7 +186,10 @@ static void ctdm_event_handler(switch_event_t *event)
...
@@ -187,7 +186,10 @@ static void ctdm_event_handler(switch_event_t *event)
return
;
return
;
}
}
ctdm_report_alarms
(
channel
,
mg_profile_name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Requesting alarm status for %s:%d
\n
"
,
ftdm_channel_get_span_name
(
channel
),
ftdm_channel_get_id
(
channel
));
ctdm_report_alarms
(
channel
);
}
}
}
}
break
;
break
;
...
...
src/mod/endpoints/mod_media_gateway/media_gateway.c
浏览文件 @
c06e3d76
...
@@ -22,6 +22,8 @@ megaco_profile_t *megaco_profile_locate(const char *name)
...
@@ -22,6 +22,8 @@ megaco_profile_t *megaco_profile_locate(const char *name)
return
profile
;
return
profile
;
}
}
mg_peer_profile_t
*
megaco_peer_profile_locate
(
const
char
*
name
)
mg_peer_profile_t
*
megaco_peer_profile_locate
(
const
char
*
name
)
{
{
mg_peer_profile_t
*
profile
=
switch_core_hash_find_rdlock
(
megaco_globals
.
peer_profile_hash
,
name
,
megaco_globals
.
peer_profile_rwlock
);
mg_peer_profile_t
*
profile
=
switch_core_hash_find_rdlock
(
megaco_globals
.
peer_profile_hash
,
name
,
megaco_globals
.
peer_profile_rwlock
);
...
@@ -171,7 +173,6 @@ switch_status_t megaco_prepare_tdm_termination(mg_termination_t *term)
...
@@ -171,7 +173,6 @@ switch_status_t megaco_prepare_tdm_termination(mg_termination_t *term)
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
/* @Kapil Call this function once H.248 link is up */
switch_status_t
megaco_check_tdm_termination
(
mg_termination_t
*
term
)
switch_status_t
megaco_check_tdm_termination
(
mg_termination_t
*
term
)
{
{
switch_event_t
*
event
=
NULL
;
switch_event_t
*
event
=
NULL
;
...
@@ -186,7 +187,6 @@ switch_status_t megaco_check_tdm_termination(mg_termination_t *term)
...
@@ -186,7 +187,6 @@ switch_status_t megaco_check_tdm_termination(mg_termination_t *term)
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"span-name"
,
"%s"
,
term
->
u
.
tdm
.
span_name
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"span-name"
,
"%s"
,
term
->
u
.
tdm
.
span_name
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"chan-number"
,
"%d"
,
term
->
u
.
tdm
.
channel
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"chan-number"
,
"%d"
,
term
->
u
.
tdm
.
channel
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"condition"
,
"mg-tdm-check"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"condition"
,
"mg-tdm-check"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"mg-profile-name"
,
term
->
profile
->
name
);
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
...
@@ -241,7 +241,34 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
...
@@ -241,7 +241,34 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
return
term
;
return
term
;
}
}
mg_termination_t
*
megaco_find_termination_by_span_chan
(
megaco_profile_t
*
profile
,
char
*
span_name
,
char
*
chan_number
)
mg_termination_t
*
megaco_term_locate_by_span_chan_id
(
const
char
*
span_name
,
const
char
*
chan_number
)
{
void
*
val
=
NULL
;
switch_hash_index_t
*
hi
=
NULL
;
mg_termination_t
*
term
=
NULL
;
megaco_profile_t
*
profile
=
NULL
;
const
void
*
var
;
switch_assert
(
span_name
);
switch_assert
(
chan_number
);
/* span + chan will be unique across all the mg_profiles *
* loop through all profiles and then all terminations to *
* get the mg termination associated with input span+chan */
switch_thread_rwlock_rdlock
(
megaco_globals
.
profile_rwlock
);
for
(
hi
=
switch_hash_first
(
NULL
,
megaco_globals
.
profile_hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
switch_hash_this
(
hi
,
&
var
,
NULL
,
&
val
);
profile
=
(
megaco_profile_t
*
)
val
;
if
(
NULL
!=
(
term
=
megaco_find_termination_by_span_chan
(
profile
,
span_name
,
chan_number
)))
break
;
}
switch_thread_rwlock_unlock
(
megaco_globals
.
profile_rwlock
);
return
term
;
}
mg_termination_t
*
megaco_find_termination_by_span_chan
(
megaco_profile_t
*
profile
,
const
char
*
span_name
,
const
char
*
chan_number
)
{
{
void
*
val
=
NULL
;
void
*
val
=
NULL
;
switch_hash_index_t
*
hi
=
NULL
;
switch_hash_index_t
*
hi
=
NULL
;
...
@@ -262,7 +289,8 @@ mg_termination_t* megaco_find_termination_by_span_chan(megaco_profile_t *profile
...
@@ -262,7 +289,8 @@ mg_termination_t* megaco_find_termination_by_span_chan(megaco_profile_t *profile
if
((
!
strcasecmp
(
span_name
,
term
->
u
.
tdm
.
span_name
))
&&
(
atoi
(
chan_number
)
==
term
->
u
.
tdm
.
channel
))
{
if
((
!
strcasecmp
(
span_name
,
term
->
u
.
tdm
.
span_name
))
&&
(
atoi
(
chan_number
)
==
term
->
u
.
tdm
.
channel
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Got term[%s] associated with span[%s], channel[%s]
\n
"
,
term
->
name
,
span_name
,
chan_number
);
"Got term[%s] associated with span[%s], channel[%s] in MG profile[%s]
\n
"
,
term
->
name
,
span_name
,
chan_number
,
profile
->
name
);
found
=
0x01
;
found
=
0x01
;
break
;
break
;
}
}
...
@@ -271,7 +299,8 @@ mg_termination_t* megaco_find_termination_by_span_chan(megaco_profile_t *profile
...
@@ -271,7 +299,8 @@ mg_termination_t* megaco_find_termination_by_span_chan(megaco_profile_t *profile
if
(
!
found
){
if
(
!
found
){
term
=
NULL
;
term
=
NULL
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
" Not able to find termination associated with span[%s], channel[%s]
\n
"
,
span_name
,
chan_number
);
" MG profile[%s] does not have termination associated with span[%s], channel[%s]
\n
"
,
profile
->
name
,
span_name
,
chan_number
);
}
}
return
term
;
return
term
;
...
@@ -549,8 +578,9 @@ switch_status_t megaco_profile_start(const char *profilename)
...
@@ -549,8 +578,9 @@ switch_status_t megaco_profile_start(const char *profilename)
switch_core_new_memory_pool
(
&
pool
);
switch_core_new_memory_pool
(
&
pool
);
profile
=
switch_core_alloc
(
pool
,
sizeof
(
*
profile
));
profile
=
switch_core_alloc
(
pool
,
sizeof
(
*
profile
));
profile
->
pool
=
pool
;
profile
->
pool
=
pool
;
profile
->
physical_terminations
=
NULL
;
profile
->
name
=
switch_core_strdup
(
pool
,
profilename
);
profile
->
name
=
switch_core_strdup
(
pool
,
profilename
);
profile
->
next_context_id
++
;
profile
->
next_context_id
++
;
profile
->
inact_tmr
=
0x00
;
profile
->
inact_tmr
=
0x00
;
profile
->
inact_tmr_task_id
=
0x00
;
profile
->
inact_tmr_task_id
=
0x00
;
...
...
src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c
浏览文件 @
c06e3d76
...
@@ -2288,18 +2288,15 @@ U32 get_txn_id(){
...
@@ -2288,18 +2288,15 @@ U32 get_txn_id(){
return
outgoing_txn_id
;
return
outgoing_txn_id
;
}
}
/*****************************************************************************************************************************/
/*****************************************************************************************************************************/
switch_status_t
mg_send_term_service_change
(
char
*
mg_profile_name
,
char
*
span_name
,
char
*
chan_number
,
mg_term_states_e
term_state
)
switch_status_t
mg_send_term_service_change
(
char
*
span_name
,
char
*
chan_number
,
mg_term_states_e
term_state
)
{
{
mg_termination_t
*
term
=
NULL
;
mg_termination_t
*
term
=
NULL
;
switch_status_t
ret
=
SWITCH_STATUS_SUCCESS
;
switch_status_t
ret
=
SWITCH_STATUS_SUCCESS
;
megaco_profile_t
*
profile
=
NULL
;
switch_assert
(
span_name
);
switch_assert
(
span_name
);
switch_assert
(
chan_number
);
switch_assert
(
chan_number
);
profile
=
megaco_profile_locate
(
mg_profile_name
);
term
=
megaco_term_locate_by_span_chan_id
(
span_name
,
chan_number
);
term
=
megaco_find_termination_by_span_chan
(
profile
,
span_name
,
chan_number
);
if
(
!
term
||
!
term
->
profile
){
if
(
!
term
||
!
term
->
profile
){
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
...
@@ -2309,12 +2306,22 @@ switch_status_t mg_send_term_service_change(char* mg_profile_name,char *span_nam
...
@@ -2309,12 +2306,22 @@ switch_status_t mg_send_term_service_change(char* mg_profile_name,char *span_nam
{
{
case
MG_TERM_SERVICE_STATE_IN_SERVICE
:
case
MG_TERM_SERVICE_STATE_IN_SERVICE
:
{
{
ret
=
mg_send_ins_service_change
(
term
->
profile
,
term
->
name
,
0x00
);
if
(
switch_test_flag
(
term
,
MG_OUT_OF_SERVICE
)){
/* set INS flag...clear oos flag */
switch_clear_flag
(
term
,
MG_OUT_OF_SERVICE
);
switch_set_flag
(
term
,
MG_IN_SERVICE
);
ret
=
mg_send_ins_service_change
(
term
->
profile
,
term
->
name
,
0x00
);
}
break
;
break
;
}
}
case
MG_TERM_SERVICE_STATE_OUT_OF_SERVICE
:
case
MG_TERM_SERVICE_STATE_OUT_OF_SERVICE
:
{
{
ret
=
mg_send_oos_service_change
(
term
->
profile
,
term
->
name
,
0x00
);
if
(
switch_test_flag
(
term
,
MG_IN_SERVICE
)){
/* set OOS flag...clear ins flag */
switch_clear_flag
(
term
,
MG_IN_SERVICE
);
switch_set_flag
(
term
,
MG_OUT_OF_SERVICE
);
ret
=
mg_send_oos_service_change
(
term
->
profile
,
term
->
name
,
0x00
);
}
break
;
break
;
}
}
default
:
default
:
...
...
src/mod/endpoints/mod_media_gateway/media_gateway_stack.h
浏览文件 @
c06e3d76
...
@@ -164,8 +164,7 @@ void mg_util_set_err_string ( MgStr *errTxt, char* str);
...
@@ -164,8 +164,7 @@ void mg_util_set_err_string ( MgStr *errTxt, char* str);
switch_status_t
mg_build_sdp
(
MgMgcoMediaDesc
*
out
,
MgMgcoMediaDesc
*
inc
,
megaco_profile_t
*
mg_profile
,
mg_termination_t
*
term
,
CmMemListCp
*
memCp
);
switch_status_t
mg_build_sdp
(
MgMgcoMediaDesc
*
out
,
MgMgcoMediaDesc
*
inc
,
megaco_profile_t
*
mg_profile
,
mg_termination_t
*
term
,
CmMemListCp
*
memCp
);
switch_status_t
mg_add_local_descriptor
(
MgMgcoMediaDesc
*
media
,
megaco_profile_t
*
mg_profile
,
mg_termination_t
*
term
,
CmMemListCp
*
memCp
);
switch_status_t
mg_add_local_descriptor
(
MgMgcoMediaDesc
*
media
,
megaco_profile_t
*
mg_profile
,
mg_termination_t
*
term
,
CmMemListCp
*
memCp
);
switch_status_t
mg_send_term_service_change
(
char
*
mg_profile_name
,
char
*
span_name
,
char
*
chan_number
,
mg_term_states_e
term_state
);
switch_status_t
mg_send_term_service_change
(
char
*
span_name
,
char
*
chan_number
,
mg_term_states_e
term_state
);
mg_termination_t
*
megaco_find_termination_by_span_chan
(
megaco_profile_t
*
profile
,
char
*
span_name
,
char
*
chan_number
);
switch_status_t
sng_mgco_cfg
(
megaco_profile_t
*
profile
);
switch_status_t
sng_mgco_cfg
(
megaco_profile_t
*
profile
);
...
@@ -190,7 +189,8 @@ void mg_util_set_txn_string(MgStr *errTxt, U32 *txnId);
...
@@ -190,7 +189,8 @@ void mg_util_set_txn_string(MgStr *errTxt, U32 *txnId);
switch_status_t
mg_build_mgco_err_request
(
MgMgcoInd
**
errcmd
,
U32
trans_id
,
MgMgcoContextId
*
ctxt_id
,
U32
err
,
MgStr
*
errTxt
);
switch_status_t
mg_build_mgco_err_request
(
MgMgcoInd
**
errcmd
,
U32
trans_id
,
MgMgcoContextId
*
ctxt_id
,
U32
err
,
MgStr
*
errTxt
);
switch_status_t
mg_send_audit_rsp
(
SuId
suId
,
MgMgcoCommand
*
req
);
switch_status_t
mg_send_audit_rsp
(
SuId
suId
,
MgMgcoCommand
*
req
);
switch_status_t
handle_mg_audit_cmd
(
SuId
suId
,
MgMgcoCommand
*
auditReq
);
switch_status_t
handle_mg_audit_cmd
(
SuId
suId
,
MgMgcoCommand
*
auditReq
);
switch_status_t
mg_stack_termination_is_in_service
(
char
*
term_str
,
int
len
);
switch_status_t
mg_stack_termination_is_in_service
(
megaco_profile_t
*
mg_profile
,
char
*
term_str
,
int
len
);
void
mg_create_tdm_term
(
megaco_profile_t
*
profile
,
const
char
*
tech
,
const
char
*
channel_prefix
,
const
char
*
prefix
,
int
j
);
void
mg_util_set_cmd_name_string
(
MgStr
*
errTxt
,
MgMgcoCommand
*
cmd
);
void
mg_util_set_cmd_name_string
(
MgStr
*
errTxt
,
MgMgcoCommand
*
cmd
);
switch_status_t
mgco_init_ins_service_change
(
SuId
suId
);
switch_status_t
mgco_init_ins_service_change
(
SuId
suId
);
...
...
src/mod/endpoints/mod_media_gateway/media_gateway_utils.c
浏览文件 @
c06e3d76
...
@@ -80,10 +80,16 @@ switch_status_t mg_stack_free_mem(void* msg)
...
@@ -80,10 +80,16 @@ switch_status_t mg_stack_free_mem(void* msg)
/*****************************************************************************************************************************/
/*****************************************************************************************************************************/
/* T
ODO - Matt - t
o see if term is in service or not */
/* To see if term is in service or not */
switch_status_t
mg_stack_termination_is_in_service
(
char
*
term_str
,
int
len
)
switch_status_t
mg_stack_termination_is_in_service
(
megaco_profile_t
*
mg_profile
,
char
*
term_str
,
int
len
)
{
{
return
SWITCH_STATUS_SUCCESS
;
mg_termination_t
*
term
=
NULL
;
term
=
megaco_find_termination
(
mg_profile
,
term_str
);
if
(
switch_test_flag
(
term
,
MG_IN_SERVICE
)){
return
SWITCH_STATUS_SUCCESS
;
}
else
{
return
SWITCH_STATUS_FALSE
;
}
}
}
/*****************************************************************************************************************************/
/*****************************************************************************************************************************/
...
...
src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
浏览文件 @
c06e3d76
...
@@ -65,62 +65,74 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
...
@@ -65,62 +65,74 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
profile
->
idx
=
++
mg_sap_id
;
profile
->
idx
=
++
mg_sap_id
;
if
((
mg_phys_terms
=
switch_xml_child
(
mg_interface
,
"physical_terminations"
)))
{
if
((
mg_phys_terms
=
switch_xml_child
(
mg_interface
,
"physical_terminations"
)))
{
for
(
mg_term
=
switch_xml_child
(
mg_phys_terms
,
"map"
);
mg_term
;
mg_term
=
mg_term
->
next
)
{
for
(
mg_term
=
switch_xml_child
(
mg_phys_terms
,
"map"
);
mg_term
;
mg_term
=
mg_term
->
next
)
{
switch_memory_pool_t
*
pool
;
// <map termination-id-prefix="Term1/" termination-id-base="1" tech="freetdm" channel-prefix="wp2" channel-map"1-15,17-31"/>
mg_termination_t
*
term
;
const
char
*
prefix
=
switch_xml_attr
(
mg_term
,
"termination-id-prefix"
);
// <map termination-id-prefix="Term1/" termination-id-base="1" tech="freetdm" channel-prefix="wp2" channel-map"1-15,17-31"/>
//const char *sztermination_id_base = switch_xml_attr(mg_term, "termination-id-base");
const
char
*
prefix
=
switch_xml_attr
(
mg_term
,
"termination-id-prefix"
);
const
char
*
tech
=
switch_xml_attr
(
mg_term
,
"tech"
);
//const char *sztermination_id_base = switch_xml_attr(mg_term, "termination-id-base");
const
char
*
channel_prefix
=
switch_xml_attr
(
mg_term
,
"channel-prefix"
);
const
char
*
tech
=
switch_xml_attr
(
mg_term
,
"tech"
);
const
char
*
channel_map
=
switch_xml_attr
(
mg_term
,
"channel-map"
);
const
char
*
channel_prefix
=
switch_xml_attr
(
mg_term
,
"channel-prefix"
);
char
*
p
=
NULL
;
const
char
*
channel_map
=
switch_xml_attr
(
mg_term
,
"channel-map"
);
if
(
!
zstr
(
channel_map
))
{
/* Split channel-map */
if
(
!
zstr
(
channel_map
))
{
char
*
channel_map_dup
=
strdup
(
channel_map
);
/* Split channel-map */
char
*
chanmap
[
24
]
=
{
0
};
char
*
channel_map_dup
=
strdup
(
channel_map
);
int
chanmap_count
=
0
;
char
*
chanmap
[
24
];
int
i
=
0
;
int
chanmap_count
,
i
;
int
startchan
,
endchan
,
j
;
chanmap_count
=
switch_split
(
channel_map_dup
,
','
,
chanmap
);
for
(
i
=
0
;
i
<
chanmap_count
;
i
++
)
{
/* we can have following combinations *
char
*
p
=
strchr
(
chanmap
[
i
],
'-'
);
* i) only one channel i.e. channel-map="1"
if
(
p
)
{
* ii) only one chanel range i.e channel-map="1-15"
int
startchan
,
endchan
,
j
;
* iii) full channel range i.e. channel-map="1-15,17-31"
*
p
++
=
'\0'
;
*/
startchan
=
atoi
(
chanmap
[
i
]);
endchan
=
atoi
(
p
);
chanmap_count
=
switch_split
(
channel_map_dup
,
','
,
chanmap
);
for
(
j
=
startchan
;
j
<
endchan
;
j
++
)
{
switch_core_new_memory_pool
(
&
pool
);
if
(
1
==
chanmap_count
)
{
term
=
switch_core_alloc
(
profile
->
pool
,
sizeof
*
term
);
p
=
strchr
(
channel_map_dup
,
'-'
);
term
->
pool
=
pool
;
if
(
NULL
!=
p
){
term
->
type
=
MG_TERM_TDM
;
/* case (ii) */
term
->
profile
=
profile
;
i
=
switch_split
(
channel_map_dup
,
'-'
,
chanmap
);
term
->
mg_ctxt
=
NULL
;
if
(
i
&&
chanmap
[
0
]
&&
chanmap
[
1
])
{
term
->
tech
=
switch_core_strdup
(
pool
,
tech
);
startchan
=
atoi
(
chanmap
[
0
]);
term
->
active_events
=
NULL
;
endchan
=
atoi
(
chanmap
[
1
]);
term
->
name
=
switch_core_sprintf
(
pool
,
"%s%d"
,
prefix
,
j
);
for
(
j
=
startchan
;
j
<
endchan
;
j
++
)
{
term
->
u
.
tdm
.
channel
=
j
;
mg_create_tdm_term
(
profile
,
tech
,
channel_prefix
,
prefix
,
j
);
term
->
u
.
tdm
.
span_name
=
switch_core_strdup
(
pool
,
channel_prefix
);
}
}
switch_core_hash_insert_wrlock
(
profile
->
terminations
,
term
->
name
,
term
,
profile
->
terminations_rwlock
);
}
else
{
term
->
next
=
profile
->
physical_terminations
;
/* case (i) */
profile
->
physical_terminations
=
term
;
p
=
channel_map_dup
;
startchan
=
endchan
=
atoi
(
p
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Mapped termination [%s] to freetdm span: %s chan: %d
\n
"
,
term
->
name
,
term
->
u
.
tdm
.
span_name
,
term
->
u
.
tdm
.
channel
);
mg_create_tdm_term
(
profile
,
tech
,
channel_prefix
,
prefix
,
startchan
);
}
megaco_prepare_tdm_termination
(
term
);
}
else
}
{
}
/* case (iii) */
}
for
(
i
=
0
;
i
<
chanmap_count
;
i
++
)
{
p
=
strchr
(
chanmap
[
i
],
'-'
);
free
(
channel_map_dup
);
if
(
p
)
{
}
*
p
++
=
'\0'
;
}
startchan
=
atoi
(
chanmap
[
i
]);
}
endchan
=
atoi
(
p
);
for
(
j
=
startchan
;
j
<
endchan
;
j
++
)
{
mg_create_tdm_term
(
profile
,
tech
,
channel_prefix
,
prefix
,
j
);
}
}
}
}
free
(
channel_map_dup
);
}
}
}
/* we should break from here , profile name should be unique */
/* we should break from here , profile name should be unique */
...
@@ -129,7 +141,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
...
@@ -129,7 +141,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
if
(
!
mg_interface
)
{
if
(
!
mg_interface
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error profile %s not found
\n
"
,
profile
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error profile %s not found
\n
"
,
profile
->
name
);
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
/* go through the peer configuration and get the mg profile associated peers only */
/* go through the peer configuration and get the mg profile associated peers only */
...
@@ -169,7 +181,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
...
@@ -169,7 +181,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
}
}
}
}
}
}
/* configure the MEGACO stack */
/* configure the MEGACO stack */
status
=
sng_mgco_cfg
(
profile
);
status
=
sng_mgco_cfg
(
profile
);
...
@@ -184,6 +196,34 @@ done:
...
@@ -184,6 +196,34 @@ done:
return
status
;
return
status
;
}
}
/****************************************************************************************************************************/
void
mg_create_tdm_term
(
megaco_profile_t
*
profile
,
const
char
*
tech
,
const
char
*
channel_prefix
,
const
char
*
prefix
,
int
chan_num
)
{
mg_termination_t
*
term
;
switch_memory_pool_t
*
pool
;
switch_core_new_memory_pool
(
&
pool
);
term
=
switch_core_alloc
(
profile
->
pool
,
sizeof
*
term
);
term
->
pool
=
pool
;
term
->
type
=
MG_TERM_TDM
;
term
->
profile
=
profile
;
term
->
mg_ctxt
=
NULL
;
term
->
tech
=
switch_core_strdup
(
pool
,
tech
);
term
->
active_events
=
NULL
;
term
->
name
=
switch_core_sprintf
(
pool
,
"%s%d"
,
prefix
,
chan_num
);
term
->
u
.
tdm
.
channel
=
chan_num
;
term
->
u
.
tdm
.
span_name
=
switch_core_strdup
(
pool
,
channel_prefix
);
switch_set_flag
(
term
,
MG_OUT_OF_SERVICE
);
switch_core_hash_insert_wrlock
(
profile
->
terminations
,
term
->
name
,
term
,
profile
->
terminations_rwlock
);
term
->
next
=
profile
->
physical_terminations
;
profile
->
physical_terminations
=
term
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Mapped termination [%s] to freetdm span: %s chan: %d
\n
"
,
term
->
name
,
term
->
u
.
tdm
.
span_name
,
term
->
u
.
tdm
.
channel
);
megaco_prepare_tdm_termination
(
term
);
}
/****************************************************************************************************************************/
/****************************************************************************************************************************/
switch_status_t
mg_config_cleanup
(
megaco_profile_t
*
profile
)
switch_status_t
mg_config_cleanup
(
megaco_profile_t
*
profile
)
{
{
...
...
src/mod/endpoints/mod_media_gateway/mod_media_gateway.c
浏览文件 @
c06e3d76
...
@@ -64,38 +64,23 @@ static void mg_event_handler(switch_event_t *event)
...
@@ -64,38 +64,23 @@ static void mg_event_handler(switch_event_t *event)
const
char
*
span_name
=
NULL
;
const
char
*
span_name
=
NULL
;
const
char
*
chan_number
=
NULL
;
const
char
*
chan_number
=
NULL
;
const
char
*
cond
=
NULL
;
const
char
*
cond
=
NULL
;
const
char
*
mg_profile_name
=
NULL
;
cond
=
switch_event_get_header
(
event
,
"condition"
);
cond
=
switch_event_get_header
(
event
,
"condition"
);
if
(
zstr
(
cond
))
{
if
(
zstr
(
cond
))
{
printf
(
"Condition NULL, returning
\n
"
);
return
;
}
mg_profile_name
=
switch_event_get_header
(
event
,
"mg-profile-name"
);
if
(
zstr
(
mg_profile_name
))
{
printf
(
"mg_profile_name NULL, returning
\n
"
);
return
;
return
;
}
}
span_name
=
switch_event_get_header
(
event
,
"span-name"
);
span_name
=
switch_event_get_header
(
event
,
"span-name"
);
chan_number
=
switch_event_get_header
(
event
,
"chan-number"
);
chan_number
=
switch_event_get_header
(
event
,
"chan-number"
);
if
(
!
strcmp
(
cond
,
"ftdm-alarm-trap"
))
{
if
(
!
strcmp
(
cond
,
"ftdm-alarm-trap"
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"ftdm-alarm-trap for span_name[%s] chan_number[%s] associated with MG profile[%s]
\n
"
,
"ftdm-alarm-trap for span_name[%s] chan_number[%s]
\n
"
,
span_name
,
chan_number
);
span_name
,
chan_number
,
mg_profile_name
);
mg_send_term_service_change
((
char
*
)
span_name
,
(
char
*
)
chan_number
,
MG_TERM_SERVICE_STATE_OUT_OF_SERVICE
);
/* @KAPIL: TDM is in alarm, notify MGC */
mg_send_term_service_change
(
(
char
*
)
mg_profile_name
,
(
char
*
)
span_name
,
(
char
*
)
chan_number
,
MG_TERM_SERVICE_STATE_OUT_OF_SERVICE
);
}
else
if
(
!
strcmp
(
cond
,
"ftdm-alarm-clear"
))
{
}
else
if
(
!
strcmp
(
cond
,
"ftdm-alarm-clear"
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"ftdm-alarm-clear for span_name[%s] chan_number[%s] associated with MG profile[%s]
\n
"
,
"ftdm-alarm-clear for span_name[%s] chan_number[%s]
\n
"
,
span_name
,
chan_number
);
span_name
,
chan_number
,
mg_profile_name
);
mg_send_term_service_change
(
(
char
*
)
span_name
,
(
char
*
)
chan_number
,
MG_TERM_SERVICE_STATE_IN_SERVICE
);
/* TDM alarm cleared, notify MGC */
mg_send_term_service_change
(
(
char
*
)
mg_profile_name
,
(
char
*
)
span_name
,
(
char
*
)
chan_number
,
MG_TERM_SERVICE_STATE_IN_SERVICE
);
}
}
}
}
break
;
break
;
...
@@ -561,8 +546,10 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
...
@@ -561,8 +546,10 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
}
}
/*If term type is other then check if that term is configured with us..for term type CHOOSE/ALL , no need to check */
/*If term type is other then check if that term is configured with us..for term type CHOOSE/ALL , no need to check */
if
(
MGT_TERMID_OTHER
==
termId
->
type
.
val
){
if
((
CH_CMD_TYPE_IND
==
cmd
->
cmdType
.
val
)
&&
if
(
SWITCH_STATUS_FALSE
==
mg_stack_termination_is_in_service
((
char
*
)
termId
->
name
.
lcl
.
val
,
termId
->
name
.
lcl
.
len
)){
(
MGT_TERMID_OTHER
==
termId
->
type
.
val
)){
if
(
SWITCH_STATUS_FALSE
==
mg_stack_termination_is_in_service
(
mg_profile
,
(
char
*
)
termId
->
name
.
lcl
.
val
,
termId
->
name
.
lcl
.
len
)){
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Termination[%s] not in service
\n
"
,
(
char
*
)
termId
->
name
.
lcl
.
val
);
mg_util_set_term_string
(
&
errTxt
,
termId
);
mg_util_set_term_string
(
&
errTxt
,
termId
);
err_code
=
MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID
;
err_code
=
MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID
;
goto
error
;
goto
error
;
...
...
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h
浏览文件 @
c06e3d76
...
@@ -89,8 +89,10 @@ typedef struct mg_context_s mg_context_t;
...
@@ -89,8 +89,10 @@ typedef struct mg_context_s mg_context_t;
typedef
struct
mg_termination_s
mg_termination_t
;
typedef
struct
mg_termination_s
mg_termination_t
;
enum
{
enum
{
MGT_ALLOCATED
=
(
1
<<
0
),
MGT_ALLOCATED
=
(
1
<<
0
),
MGT_ACTIVE
=
(
1
<<
1
),
MGT_ACTIVE
=
(
1
<<
1
),
MG_IN_SERVICE
=
(
1
<<
2
),
MG_OUT_OF_SERVICE
=
(
1
<<
3
),
}
mg_termination_flags
;
}
mg_termination_flags
;
...
@@ -222,8 +224,10 @@ static inline megaco_codec_t megaco_codec_parse(const char *codec) {
...
@@ -222,8 +224,10 @@ static inline megaco_codec_t megaco_codec_parse(const char *codec) {
megaco_profile_t
*
megaco_profile_locate
(
const
char
*
name
);
megaco_profile_t
*
megaco_profile_locate
(
const
char
*
name
);
mg_termination_t
*
megaco_term_locate_by_span_chan_id
(
const
char
*
span_name
,
const
char
*
chan_number
);
mg_peer_profile_t
*
megaco_peer_profile_locate
(
const
char
*
name
);
mg_peer_profile_t
*
megaco_peer_profile_locate
(
const
char
*
name
);
void
megaco_profile_release
(
megaco_profile_t
*
profile
);
void
megaco_profile_release
(
megaco_profile_t
*
profile
);
mg_termination_t
*
megaco_find_termination_by_span_chan
(
megaco_profile_t
*
profile
,
const
char
*
span_name
,
const
char
*
chan_number
);
switch_status_t
megaco_profile_start
(
const
char
*
profilename
);
switch_status_t
megaco_profile_start
(
const
char
*
profilename
);
switch_status_t
megaco_profile_destroy
(
megaco_profile_t
**
profile
);
switch_status_t
megaco_profile_destroy
(
megaco_profile_t
**
profile
);
...
...
src/mod/endpoints/mod_opal/mod_opal.cpp
浏览文件 @
c06e3d76
差异被折叠。
点击展开。
src/mod/endpoints/mod_opal/mod_opal.h
浏览文件 @
c06e3d76
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论