Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c1bc9ac7
提交
c1bc9ac7
authored
7月 03, 2012
作者:
David Yat Sin
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'nsg-4.3' of
ssh://git.sangoma.com/smg_freeswitch
into nsg-4.3
上级
5925e256
32a7e006
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
21 行删除
+24
-21
media_gateway_xml.c
src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
+24
-21
没有找到文件。
src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
浏览文件 @
c1bc9ac7
...
...
@@ -12,7 +12,7 @@
static
switch_xml_config_item_t
*
get_instructions
(
megaco_profile_t
*
profile
)
;
static
switch_xml_config_item_t
*
get_peer_instructions
(
mg_peer_profile_t
*
profile
)
;
static
int
mg_sap_id
;
static
switch_status_t
modify_mid
(
char
*
mid
);
static
switch_status_t
modify_mid
(
char
*
*
p
mid
);
/****************************************************************************************************************************/
switch_status_t
config_profile
(
megaco_profile_t
*
profile
,
switch_bool_t
reload
)
...
...
@@ -59,10 +59,11 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
profile
->
total_peers
++
;
}
if
(
SWITCH_STATUS_FALSE
==
(
status
=
modify_mid
(
profile
->
mid
))){
if
(
SWITCH_STATUS_FALSE
==
(
status
=
modify_mid
(
&
profile
->
mid
))){
goto
done
;
}
profile
->
idx
=
++
mg_sap_id
;
/* we should break from here , profile name should be unique */
...
...
@@ -100,7 +101,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
goto
done
;
}
if
(
SWITCH_STATUS_FALSE
==
(
status
=
modify_mid
(
peer_profile
->
mid
))){
if
(
SWITCH_STATUS_FALSE
==
(
status
=
modify_mid
(
&
peer_profile
->
mid
))){
goto
done
;
}
...
...
@@ -213,55 +214,57 @@ static switch_xml_config_item_t *get_instructions(megaco_profile_t *profile) {
/****************************************************************************************************************************/
static
switch_status_t
modify_mid
(
char
*
mid
)
static
switch_status_t
modify_mid
(
char
*
*
p
mid
)
{
char
dup
[
64
];
char
*
mid
=
*
pmid
;
char
*
dup
;
char
*
val
[
10
];
int
count
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_assert
(
mid
);
memset
(
&
dup
[
0
],
0
,
sizeof
(
dup
)
);
dup
=
strdup
(
mid
);
/* If MID type is IP then add mid into [] brackets ,
* If MID type is domain then add mid into <> brackets *
*/
strcpy
(
&
dup
[
0
],
mid
);
count
=
switch_split
(
&
dup
[
0
],
'.'
,
val
);
count
=
switch_split
(
dup
,
'.'
,
val
);
if
(
!
count
)
{
/* Input string is not separated by '.', check if its separated by '-' as format could be xxx-xx-xxx/xxx-xx-xx-xxx */
memset
(
&
dup
[
0
],
0
,
sizeof
(
dup
));
strcpy
(
&
dup
[
0
],
mid
);
if
(
0
==
(
count
=
switch_split
(
dup
,
'-'
,
val
))){
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Invalid input MID string[%s]
\n
"
,
mid
);
return
SWITCH_STATUS_FALSE
;
goto
done
;
}
}
if
((
'<'
==
val
[
0
][
0
])
||
(
'['
==
val
[
0
][
0
])){
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"MID = %s is already prefixed with proper brackets
\n
"
,
mid
);
return
SWITCH_STATUS_SUCCESS
;
status
=
SWITCH_STATUS_SUCCESS
;
goto
done
;
}
/*first check could be if count is 3 means domain name as generally we have xxx-xx-xxx/xxx.xx.xxx domain */
if
(
3
==
count
){
/* domain-type, add value into <> */
memset
(
&
dup
[
0
],
0
,
sizeof
(
dup
)
);
strcpy
(
&
dup
[
0
],
mid
);
sprintf
(
mid
,
"<%s>"
,
dup
)
;
*
pmid
=
switch_mprintf
(
"<%s>"
,
mid
);
free
(
mid
);
mid
=
*
pmid
;
}
else
if
(
4
==
count
){
/* IP address in xxx.xxx.xxx.xxx format */
memset
(
&
dup
[
0
],
0
,
sizeof
(
dup
)
);
strcpy
(
&
dup
[
0
],
mid
);
sprintf
(
mid
,
"[%s]"
,
dup
)
;
*
pmid
=
switch_mprintf
(
"[%s]"
,
mid
);
free
(
mid
);
mid
=
*
pmid
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Invalid input MID string[%s]
\n
"
,
mid
);
return
SWITCH_STATUS_FALSE
;
goto
done
;
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Added proper brackets to MID = %s
\n
"
,
mid
);
return
SWITCH_STATUS_SUCCESS
;
status
=
SWITCH_STATUS_SUCCESS
;
done:
return
status
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论