Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
6fef880f
提交
6fef880f
authored
1月 23, 2014
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-5675 --resolve
上级
b5821c15
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
63 行增加
和
8 行删除
+63
-8
switch.conf.xml
conf/vanilla/autoload_configs/switch.conf.xml
+3
-0
switch_core_pvt.h
src/include/private/switch_core_pvt.h
+1
-0
switch_core.h
src/include/switch_core.h
+2
-1
switch_types.h
src/include/switch_types.h
+3
-1
switch_core.c
src/switch_core.c
+2
-0
switch_core_port_allocator.c
src/switch_core_port_allocator.c
+51
-5
switch_rtp.c
src/switch_rtp.c
+1
-1
没有找到文件。
conf/vanilla/autoload_configs/switch.conf.xml
浏览文件 @
6fef880f
...
@@ -142,6 +142,9 @@
...
@@ -142,6 +142,9 @@
<!-- <param name="rtp-start-port" value="16384"/> -->
<!-- <param name="rtp-start-port" value="16384"/> -->
<!-- <param name="rtp-end-port" value="32768"/> -->
<!-- <param name="rtp-end-port" value="32768"/> -->
<!-- Test each port to make sure it is not in use by some other process before allocating it to RTP -->
<!-- <param name="rtp-port-usage-robustness" value="true"/> -->
<param
name=
"rtp-enable-zrtp"
value=
"true"
/>
<param
name=
"rtp-enable-zrtp"
value=
"true"
/>
<!-- <param name="core-db-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE' application_name='freeswitch'" /> -->
<!-- <param name="core-db-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE' application_name='freeswitch'" /> -->
...
...
src/include/private/switch_core_pvt.h
浏览文件 @
6fef880f
...
@@ -277,6 +277,7 @@ struct switch_runtime {
...
@@ -277,6 +277,7 @@ struct switch_runtime {
char
*
core_db_inner_pre_trans_execute
;
char
*
core_db_inner_pre_trans_execute
;
char
*
core_db_inner_post_trans_execute
;
char
*
core_db_inner_post_trans_execute
;
int
events_use_dispatch
;
int
events_use_dispatch
;
uint32_t
port_alloc_flags
;
};
};
extern
struct
switch_runtime
runtime
;
extern
struct
switch_runtime
runtime
;
...
...
src/include/switch_core.h
浏览文件 @
6fef880f
...
@@ -415,7 +415,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_set_pre_buffer_framecount(
...
@@ -415,7 +415,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_set_pre_buffer_framecount(
\param new_allocator new pointer for the return value
\param new_allocator new pointer for the return value
\return SWITCH_STATUS_SUCCESS if the operation was a success
\return SWITCH_STATUS_SUCCESS if the operation was a success
*/
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_core_port_allocator_new
(
_In_
switch_port_t
start
,
SWITCH_DECLARE
(
switch_status_t
)
switch_core_port_allocator_new
(
_In_
const
char
*
ip
,
_In_
switch_port_t
start
,
_In_
switch_port_t
end
,
_In_
switch_port_t
end
,
_In_
switch_port_flag_t
flags
,
_Out_
switch_core_port_allocator_t
**
new_allocator
);
_In_
switch_port_flag_t
flags
,
_Out_
switch_core_port_allocator_t
**
new_allocator
);
...
...
src/include/switch_types.h
浏览文件 @
6fef880f
...
@@ -311,7 +311,9 @@ typedef uint32_t switch_originate_flag_t;
...
@@ -311,7 +311,9 @@ typedef uint32_t switch_originate_flag_t;
typedef
enum
{
typedef
enum
{
SPF_NONE
=
0
,
SPF_NONE
=
0
,
SPF_ODD
=
(
1
<<
0
),
SPF_ODD
=
(
1
<<
0
),
SPF_EVEN
=
(
1
<<
1
)
SPF_EVEN
=
(
1
<<
1
),
SPF_ROBUST_TCP
=
(
1
<<
2
),
SPF_ROBUST_UDP
=
(
1
<<
3
)
}
switch_port_flag_enum_t
;
}
switch_port_flag_enum_t
;
typedef
uint32_t
switch_port_flag_t
;
typedef
uint32_t
switch_port_flag_t
;
...
...
src/switch_core.c
浏览文件 @
6fef880f
...
@@ -2014,6 +2014,8 @@ static void switch_load_core_config(const char *file)
...
@@ -2014,6 +2014,8 @@ static void switch_load_core_config(const char *file)
switch_rtp_set_start_port
((
switch_port_t
)
atoi
(
val
));
switch_rtp_set_start_port
((
switch_port_t
)
atoi
(
val
));
}
else
if
(
!
strcasecmp
(
var
,
"rtp-end-port"
)
&&
!
zstr
(
val
))
{
}
else
if
(
!
strcasecmp
(
var
,
"rtp-end-port"
)
&&
!
zstr
(
val
))
{
switch_rtp_set_end_port
((
switch_port_t
)
atoi
(
val
));
switch_rtp_set_end_port
((
switch_port_t
)
atoi
(
val
));
}
else
if
(
!
strcasecmp
(
var
,
"rtp-port-usage-robustness"
)
&&
switch_true
(
val
))
{
runtime
.
port_alloc_flags
|=
SPF_ROBUST_UDP
;
}
else
if
(
!
strcasecmp
(
var
,
"core-db-name"
)
&&
!
zstr
(
val
))
{
}
else
if
(
!
strcasecmp
(
var
,
"core-db-name"
)
&&
!
zstr
(
val
))
{
runtime
.
dbname
=
switch_core_strdup
(
runtime
.
memory_pool
,
val
);
runtime
.
dbname
=
switch_core_strdup
(
runtime
.
memory_pool
,
val
);
}
else
if
(
!
strcasecmp
(
var
,
"core-db-dsn"
)
&&
!
zstr
(
val
))
{
}
else
if
(
!
strcasecmp
(
var
,
"core-db-dsn"
)
&&
!
zstr
(
val
))
{
...
...
src/switch_core_port_allocator.c
浏览文件 @
6fef880f
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include "private/switch_core_pvt.h"
#include "private/switch_core_pvt.h"
struct
switch_core_port_allocator
{
struct
switch_core_port_allocator
{
char
*
ip
;
switch_port_t
start
;
switch_port_t
start
;
switch_port_t
end
;
switch_port_t
end
;
switch_port_t
next
;
switch_port_t
next
;
...
@@ -47,7 +48,7 @@ struct switch_core_port_allocator {
...
@@ -47,7 +48,7 @@ struct switch_core_port_allocator {
switch_memory_pool_t
*
pool
;
switch_memory_pool_t
*
pool
;
};
};
SWITCH_DECLARE
(
switch_status_t
)
switch_core_port_allocator_new
(
switch_port_t
start
,
SWITCH_DECLARE
(
switch_status_t
)
switch_core_port_allocator_new
(
const
char
*
ip
,
switch_port_t
start
,
switch_port_t
end
,
switch_port_flag_t
flags
,
switch_core_port_allocator_t
**
new_allocator
)
switch_port_t
end
,
switch_port_flag_t
flags
,
switch_core_port_allocator_t
**
new_allocator
)
{
{
switch_status_t
status
;
switch_status_t
status
;
...
@@ -65,9 +66,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(switch_port_t sta
...
@@ -65,9 +66,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(switch_port_t sta
}
}
alloc
->
flags
=
flags
;
alloc
->
flags
=
flags
;
alloc
->
ip
=
switch_core_strdup
(
pool
,
ip
);
even
=
switch_test_flag
(
alloc
,
SPF_EVEN
);
even
=
switch_test_flag
(
alloc
,
SPF_EVEN
);
odd
=
switch_test_flag
(
alloc
,
SPF_ODD
);
odd
=
switch_test_flag
(
alloc
,
SPF_ODD
);
alloc
->
flags
|=
runtime
.
port_alloc_flags
;
if
(
!
(
even
&&
odd
))
{
if
(
!
(
even
&&
odd
))
{
if
(
even
)
{
if
(
even
)
{
if
((
start
%
2
)
!=
0
)
{
if
((
start
%
2
)
!=
0
)
{
...
@@ -110,6 +115,31 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(switch_port_t sta
...
@@ -110,6 +115,31 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(switch_port_t sta
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
static
switch_bool_t
test_port
(
switch_core_port_allocator_t
*
alloc
,
int
family
,
int
type
,
switch_port_t
port
)
{
switch_memory_pool_t
*
pool
=
NULL
;
switch_sockaddr_t
*
local_addr
=
NULL
;
switch_socket_t
*
sock
=
NULL
;
switch_bool_t
r
=
SWITCH_FALSE
;
if
(
switch_core_new_memory_pool
(
&
pool
)
!=
SWITCH_STATUS_SUCCESS
)
{
return
SWITCH_FALSE
;
}
if
(
switch_sockaddr_info_get
(
&
local_addr
,
alloc
->
ip
,
SWITCH_UNSPEC
,
port
,
0
,
pool
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_socket_create
(
&
sock
,
family
,
type
,
0
,
pool
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_socket_bind
(
sock
,
local_addr
)
==
SWITCH_STATUS_SUCCESS
)
{
r
=
SWITCH_TRUE
;
}
switch_socket_close
(
sock
);
}
}
switch_core_destroy_memory_pool
(
&
pool
);
return
r
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_core_port_allocator_request_port
(
switch_core_port_allocator_t
*
alloc
,
switch_port_t
*
port_ptr
)
SWITCH_DECLARE
(
switch_status_t
)
switch_core_port_allocator_request_port
(
switch_core_port_allocator_t
*
alloc
,
switch_port_t
*
port_ptr
)
{
{
switch_port_t
port
=
0
;
switch_port_t
port
=
0
;
...
@@ -139,9 +169,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_request_port(switch_c
...
@@ -139,9 +169,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_request_port(switch_c
}
}
if
(
tries
<
alloc
->
track_len
)
{
if
(
tries
<
alloc
->
track_len
)
{
alloc
->
track
[
index
]
=
1
;
switch_bool_t
r
=
SWITCH_TRUE
;
alloc
->
track_used
++
;
status
=
SWITCH_STATUS_SUCCESS
;
if
((
even
&&
odd
))
{
if
((
even
&&
odd
))
{
port
=
(
switch_port_t
)
(
index
+
alloc
->
start
);
port
=
(
switch_port_t
)
(
index
+
alloc
->
start
);
...
@@ -149,7 +177,25 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_request_port(switch_c
...
@@ -149,7 +177,25 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_request_port(switch_c
port
=
(
switch_port_t
)
(
index
+
(
alloc
->
start
/
2
));
port
=
(
switch_port_t
)
(
index
+
(
alloc
->
start
/
2
));
port
*=
2
;
port
*=
2
;
}
}
goto
end
;
if
((
alloc
->
flags
&
SPF_ROBUST_UDP
))
{
r
=
test_port
(
alloc
,
AF_INET
,
SOCK_DGRAM
,
port
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"UDP port robustness check for port %d %s
\n
"
,
port
,
r
?
"pass"
:
"fail"
);
}
if
((
alloc
->
flags
&
SPF_ROBUST_TCP
))
{
r
=
test_port
(
alloc
,
AF_INET
,
SOCK_STREAM
,
port
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"TCP port robustness check for port %d %s
\n
"
,
port
,
r
?
"pass"
:
"fail"
);
}
if
(
r
)
{
alloc
->
track
[
index
]
=
1
;
alloc
->
track_used
++
;
status
=
SWITCH_STATUS_SUCCESS
;
goto
end
;
}
else
{
alloc
->
track
[
index
]
=
-
4
;
}
}
}
}
}
...
...
src/switch_rtp.c
浏览文件 @
6fef880f
...
@@ -1869,7 +1869,7 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(const char *ip)
...
@@ -1869,7 +1869,7 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(const char *ip)
switch_mutex_lock
(
port_lock
);
switch_mutex_lock
(
port_lock
);
alloc
=
switch_core_hash_find
(
alloc_hash
,
ip
);
alloc
=
switch_core_hash_find
(
alloc_hash
,
ip
);
if
(
!
alloc
)
{
if
(
!
alloc
)
{
if
(
switch_core_port_allocator_new
(
START_PORT
,
END_PORT
,
SPF_EVEN
,
&
alloc
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_port_allocator_new
(
ip
,
START_PORT
,
END_PORT
,
SPF_EVEN
,
&
alloc
)
!=
SWITCH_STATUS_SUCCESS
)
{
abort
();
abort
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论