Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
008f9889
提交
008f9889
authored
4月 01, 2011
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3208 --resolve
上级
5382972a
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
58 行增加
和
8 行删除
+58
-8
switch_nat.h
src/include/switch_nat.h
+6
-1
switch_types.h
src/include/switch_types.h
+2
-1
mod_commands.c
src/mod/applications/mod_commands/mod_commands.c
+20
-1
switch.c
src/switch.c
+8
-2
switch_core.c
src/switch_core.c
+1
-1
switch_nat.c
src/switch_nat.c
+21
-2
没有找到文件。
src/include/switch_nat.h
浏览文件 @
008f9889
...
@@ -56,7 +56,7 @@ SWITCH_DECLARE(const char *) switch_nat_get_type(void);
...
@@ -56,7 +56,7 @@ SWITCH_DECLARE(const char *) switch_nat_get_type(void);
\param pool the memory pool to use for long term allocations
\param pool the memory pool to use for long term allocations
\note Generally called by the core_init
\note Generally called by the core_init
*/
*/
SWITCH_DECLARE
(
void
)
switch_nat_init
(
switch_memory_pool_t
*
pool
);
SWITCH_DECLARE
(
void
)
switch_nat_init
(
switch_memory_pool_t
*
pool
,
switch_bool_t
mapping
);
/*!
/*!
\brief Initilize the rest of the NAT Traversal System
\brief Initilize the rest of the NAT Traversal System
...
@@ -86,6 +86,11 @@ SWITCH_DECLARE(void) switch_nat_republish(void);
...
@@ -86,6 +86,11 @@ SWITCH_DECLARE(void) switch_nat_republish(void);
*/
*/
SWITCH_DECLARE
(
void
)
switch_nat_reinit
(
void
);
SWITCH_DECLARE
(
void
)
switch_nat_reinit
(
void
);
/*!
\brief Update the setting if port mapping will be created
*/
SWITCH_DECLARE
(
void
)
switch_nat_set_mapping
(
switch_bool_t
mapping
);
/*!
/*!
\brief Maps a port through the NAT Traversal System
\brief Maps a port through the NAT Traversal System
\param port Internal port to map
\param port Internal port to map
...
...
src/include/switch_types.h
浏览文件 @
008f9889
...
@@ -265,7 +265,8 @@ typedef enum {
...
@@ -265,7 +265,8 @@ typedef enum {
SCF_VERBOSE_EVENTS
=
(
1
<<
11
),
SCF_VERBOSE_EVENTS
=
(
1
<<
11
),
SCF_USE_WIN32_MONOTONIC
=
(
1
<<
12
),
SCF_USE_WIN32_MONOTONIC
=
(
1
<<
12
),
SCF_AUTO_SCHEMAS
=
(
1
<<
13
),
SCF_AUTO_SCHEMAS
=
(
1
<<
13
),
SCF_MINIMAL
=
(
1
<<
14
)
SCF_MINIMAL
=
(
1
<<
14
),
SCF_USE_NAT_MAPPING
=
(
1
<<
15
)
}
switch_core_flag_enum_t
;
}
switch_core_flag_enum_t
;
typedef
uint32_t
switch_core_flag_t
;
typedef
uint32_t
switch_core_flag_t
;
...
...
src/mod/applications/mod_commands/mod_commands.c
浏览文件 @
008f9889
...
@@ -329,6 +329,7 @@ SWITCH_STANDARD_API(nat_map_function)
...
@@ -329,6 +329,7 @@ SWITCH_STANDARD_API(nat_map_function)
switch_port_t
external_port
=
0
;
switch_port_t
external_port
=
0
;
char
*
tmp
=
NULL
;
char
*
tmp
=
NULL
;
switch_bool_t
sticky
=
SWITCH_FALSE
;
switch_bool_t
sticky
=
SWITCH_FALSE
;
switch_bool_t
mapping
=
SWITCH_TRUE
;
if
(
!
cmd
)
{
if
(
!
cmd
)
{
goto
usage
;
goto
usage
;
...
@@ -363,6 +364,24 @@ SWITCH_STANDARD_API(nat_map_function)
...
@@ -363,6 +364,24 @@ SWITCH_STANDARD_API(nat_map_function)
goto
ok
;
goto
ok
;
}
}
if
(
argc
<
2
)
{
goto
usage
;
}
if
(
argv
[
0
]
&&
switch_stristr
(
"mapping"
,
argv
[
0
]))
{
if
(
argv
[
1
]
&&
switch_stristr
(
"enable"
,
argv
[
1
]))
{
mapping
=
SWITCH_TRUE
;
}
else
if
(
argv
[
1
]
&&
switch_stristr
(
"disable"
,
argv
[
1
]))
{
mapping
=
SWITCH_FALSE
;
}
switch_nat_set_mapping
(
mapping
);
tmp
=
switch_nat_status
();
stream
->
write_function
(
stream
,
tmp
);
switch_safe_free
(
tmp
);
goto
ok
;
}
if
(
argc
<
3
)
{
if
(
argc
<
3
)
{
goto
error
;
goto
error
;
}
}
...
@@ -395,7 +414,7 @@ SWITCH_STANDARD_API(nat_map_function)
...
@@ -395,7 +414,7 @@ SWITCH_STANDARD_API(nat_map_function)
goto
ok
;
goto
ok
;
usage
:
usage
:
stream
->
write_function
(
stream
,
"USAGE: nat_map [status|reinit|republish] | [add|del] <port> [tcp|udp] [sticky]"
);
stream
->
write_function
(
stream
,
"USAGE: nat_map [status|reinit|republish] | [add|del] <port> [tcp|udp] [sticky]
| [mapping] <enable|disable>
"
);
ok
:
ok
:
...
...
src/switch.c
浏览文件 @
008f9889
...
@@ -200,7 +200,7 @@ void WINAPI ServiceCtrlHandler(DWORD control)
...
@@ -200,7 +200,7 @@ void WINAPI ServiceCtrlHandler(DWORD control)
/* the main service entry point */
/* the main service entry point */
void
WINAPI
service_main
(
DWORD
numArgs
,
char
**
args
)
void
WINAPI
service_main
(
DWORD
numArgs
,
char
**
args
)
{
{
switch_core_flag_t
flags
=
SCF_USE_SQL
|
SCF_USE_AUTO_NAT
|
SCF_CALIBRATE_CLOCK
|
SCF_USE_CLOCK_RT
;
switch_core_flag_t
flags
=
SCF_USE_SQL
|
SCF_USE_AUTO_NAT
|
SCF_
USE_NAT_MAPPING
|
SCF_
CALIBRATE_CLOCK
|
SCF_USE_CLOCK_RT
;
const
char
*
err
=
NULL
;
/* error value for return from freeswitch initialization */
const
char
*
err
=
NULL
;
/* error value for return from freeswitch initialization */
/* Override flags if they have been set earlier */
/* Override flags if they have been set earlier */
...
@@ -364,7 +364,7 @@ int main(int argc, char *argv[])
...
@@ -364,7 +364,7 @@ int main(int argc, char *argv[])
#ifdef __sun
#ifdef __sun
switch_core_flag_t
flags
=
SCF_USE_SQL
;
switch_core_flag_t
flags
=
SCF_USE_SQL
;
#else
#else
switch_core_flag_t
flags
=
SCF_USE_SQL
|
SCF_USE_AUTO_NAT
|
SCF_CALIBRATE_CLOCK
|
SCF_USE_CLOCK_RT
;
switch_core_flag_t
flags
=
SCF_USE_SQL
|
SCF_USE_AUTO_NAT
|
SCF_
USE_NAT_MAPPING
|
SCF_
CALIBRATE_CLOCK
|
SCF_USE_CLOCK_RT
;
#endif
#endif
int
ret
=
0
;
int
ret
=
0
;
switch_status_t
destroy_status
;
switch_status_t
destroy_status
;
...
@@ -412,6 +412,7 @@ int main(int argc, char *argv[])
...
@@ -412,6 +412,7 @@ int main(int argc, char *argv[])
"
\t
-nosql -- disable internal sql scoreboard
\n
"
"
\t
-nosql -- disable internal sql scoreboard
\n
"
"
\t
-heavy-timer -- Heavy Timer, possibly more accurate but at a cost
\n
"
"
\t
-heavy-timer -- Heavy Timer, possibly more accurate but at a cost
\n
"
"
\t
-nonat -- disable auto nat detection
\n
"
"
\t
-nonat -- disable auto nat detection
\n
"
"
\t
-nonatmap -- disable auto nat port mapping
\n
"
"
\t
-nocal -- disable clock calibration
\n
"
"
\t
-nocal -- disable clock calibration
\n
"
"
\t
-nort -- disable clock clock_realtime
\n
"
"
\t
-nort -- disable clock clock_realtime
\n
"
"
\t
-stop -- stop freeswitch
\n
"
"
\t
-stop -- stop freeswitch
\n
"
...
@@ -580,6 +581,11 @@ int main(int argc, char *argv[])
...
@@ -580,6 +581,11 @@ int main(int argc, char *argv[])
known_opt
++
;
known_opt
++
;
}
}
if
(
local_argv
[
x
]
&&
!
strcmp
(
local_argv
[
x
],
"-nonatmap"
))
{
flags
&=
~
SCF_USE_NAT_MAPPING
;
known_opt
++
;
}
if
(
local_argv
[
x
]
&&
!
strcmp
(
local_argv
[
x
],
"-heavy-timer"
))
{
if
(
local_argv
[
x
]
&&
!
strcmp
(
local_argv
[
x
],
"-heavy-timer"
))
{
flags
|=
SCF_USE_HEAVY_TIMING
;
flags
|=
SCF_USE_HEAVY_TIMING
;
known_opt
++
;
known_opt
++
;
...
...
src/switch_core.c
浏览文件 @
008f9889
...
@@ -1398,7 +1398,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
...
@@ -1398,7 +1398,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
}
}
if
(
switch_test_flag
((
&
runtime
),
SCF_USE_AUTO_NAT
))
{
if
(
switch_test_flag
((
&
runtime
),
SCF_USE_AUTO_NAT
))
{
switch_nat_init
(
runtime
.
memory_pool
);
switch_nat_init
(
runtime
.
memory_pool
,
switch_test_flag
((
&
runtime
),
SCF_USE_NAT_MAPPING
)
);
}
}
switch_log_init
(
runtime
.
memory_pool
,
runtime
.
colorize_console
);
switch_log_init
(
runtime
.
memory_pool
,
runtime
.
colorize_console
);
...
...
src/switch_nat.c
浏览文件 @
008f9889
...
@@ -51,6 +51,7 @@ typedef struct {
...
@@ -51,6 +51,7 @@ typedef struct {
char
*
descURL
;
char
*
descURL
;
char
pub_addr
[
IP_LEN
];
char
pub_addr
[
IP_LEN
];
char
pvt_addr
[
IP_LEN
];
char
pvt_addr
[
IP_LEN
];
switch_bool_t
mapping
;
}
nat_globals_t
;
}
nat_globals_t
;
static
nat_globals_t
nat_globals
;
static
nat_globals_t
nat_globals
;
...
@@ -207,9 +208,14 @@ static int init_pmp(void)
...
@@ -207,9 +208,14 @@ static int init_pmp(void)
return
get_pmp_pubaddr
(
nat_globals
.
pub_addr
);
return
get_pmp_pubaddr
(
nat_globals
.
pub_addr
);
}
}
SWITCH_DECLARE
(
void
)
switch_nat_set_mapping
(
switch_bool_t
mapping
)
{
nat_globals
.
mapping
=
mapping
;
}
SWITCH_DECLARE
(
void
)
switch_nat_reinit
(
void
)
SWITCH_DECLARE
(
void
)
switch_nat_reinit
(
void
)
{
{
switch_nat_init
(
nat_globals_perm
.
pool
);
switch_nat_init
(
nat_globals_perm
.
pool
,
nat_globals
.
mapping
);
}
}
switch_status_t
init_nat_monitor
(
switch_memory_pool_t
*
pool
)
switch_status_t
init_nat_monitor
(
switch_memory_pool_t
*
pool
)
...
@@ -392,7 +398,7 @@ SWITCH_DECLARE(void) switch_nat_thread_stop(void)
...
@@ -392,7 +398,7 @@ SWITCH_DECLARE(void) switch_nat_thread_stop(void)
}
}
SWITCH_DECLARE
(
void
)
switch_nat_init
(
switch_memory_pool_t
*
pool
)
SWITCH_DECLARE
(
void
)
switch_nat_init
(
switch_memory_pool_t
*
pool
,
switch_bool_t
mapping
)
{
{
/* try free dynamic data structures prior to resetting to 0 */
/* try free dynamic data structures prior to resetting to 0 */
FreeUPNPUrls
(
&
nat_globals
.
urls
);
FreeUPNPUrls
(
&
nat_globals
.
urls
);
...
@@ -405,6 +411,8 @@ SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool)
...
@@ -405,6 +411,8 @@ SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool)
nat_globals_perm
.
pool
=
pool
;
nat_globals_perm
.
pool
=
pool
;
}
}
nat_globals
.
mapping
=
mapping
;
switch_find_local_ip
(
nat_globals
.
pvt_addr
,
sizeof
(
nat_globals
.
pvt_addr
),
NULL
,
AF_INET
);
switch_find_local_ip
(
nat_globals
.
pvt_addr
,
sizeof
(
nat_globals
.
pvt_addr
),
NULL
,
AF_INET
);
...
@@ -577,6 +585,11 @@ SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping_internal(switch_port_t po
...
@@ -577,6 +585,11 @@ SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping_internal(switch_port_t po
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_event_t
*
event
=
NULL
;
switch_event_t
*
event
=
NULL
;
if
(
!
nat_globals
.
mapping
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"NAT port mapping disabled
\n
"
);
return
status
;
}
switch
(
nat_globals
.
nat_type
)
{
switch
(
nat_globals
.
nat_type
)
{
case
SWITCH_NAT_TYPE_PMP
:
case
SWITCH_NAT_TYPE_PMP
:
status
=
switch_nat_add_mapping_pmp
(
port
,
proto
,
external_port
);
status
=
switch_nat_add_mapping_pmp
(
port
,
proto
,
external_port
);
...
@@ -710,6 +723,12 @@ SWITCH_DECLARE(char *) switch_nat_status(void)
...
@@ -710,6 +723,12 @@ SWITCH_DECLARE(char *) switch_nat_status(void)
(
nat_globals
.
nat_type
==
SWITCH_NAT_TYPE_UPNP
)
?
"UPNP"
:
(
nat_globals
.
nat_type
==
SWITCH_NAT_TYPE_PMP
?
"NAT-PMP"
:
"UNKNOWN"
),
(
nat_globals
.
nat_type
==
SWITCH_NAT_TYPE_UPNP
)
?
"UPNP"
:
(
nat_globals
.
nat_type
==
SWITCH_NAT_TYPE_PMP
?
"NAT-PMP"
:
"UNKNOWN"
),
nat_globals
.
pub_addr
);
nat_globals
.
pub_addr
);
if
(
nat_globals
.
mapping
)
{
stream
.
write_function
(
&
stream
,
"NAT port mapping enabled.
\n
"
);
}
else
{
stream
.
write_function
(
&
stream
,
"NAT port mapping disabled.
\n
"
);
}
switch_api_execute
(
"show"
,
"nat_map"
,
NULL
,
&
stream
);
switch_api_execute
(
"show"
,
"nat_map"
,
NULL
,
&
stream
);
return
stream
.
data
;
/* caller frees */
return
stream
.
data
;
/* caller frees */
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论