Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
15011c4f
提交
15011c4f
authored
12月 16, 2011
作者:
Marc Olivier Chouinard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3768 --resolve
上级
6d7ab6e2
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
53 行增加
和
38 行删除
+53
-38
mod_sofia.h
src/mod/endpoints/mod_sofia/mod_sofia.h
+1
-0
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+1
-1
sofia_reg.c
src/mod/endpoints/mod_sofia/sofia_reg.c
+51
-37
没有找到文件。
src/mod/endpoints/mod_sofia/mod_sofia.h
浏览文件 @
15011c4f
...
...
@@ -800,6 +800,7 @@ typedef enum {
AUTH_OK
,
AUTH_FORBIDDEN
,
AUTH_STALE
,
AUTH_RENEWED
,
}
auth_res_t
;
typedef
struct
{
...
...
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
15011c4f
...
...
@@ -952,7 +952,7 @@ static void our_sofia_event_callback(nua_event_t event,
REG_INVITE
,
NULL
,
NULL
,
NULL
);
}
if
(
auth_res
!=
AUTH_OK
)
{
if
(
(
auth_res
!=
AUTH_OK
&&
auth_res
!=
AUTH_RENEWED
)
)
{
//switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
nua_respond
(
nh
,
SIP_401_UNAUTHORIZED
,
TAG_END
());
goto
done
;
...
...
src/mod/endpoints/mod_sofia/sofia_reg.c
浏览文件 @
15011c4f
...
...
@@ -1371,7 +1371,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
}
if
(
auth_res
!=
AUTH_OK
&&
!
stale
)
{
if
(
auth_res
!=
AUTH_OK
&&
auth_res
!=
AUTH_RENEWED
&&
!
stale
)
{
if
(
auth_res
==
AUTH_FORBIDDEN
)
{
nua_respond
(
nh
,
SIP_403_FORBIDDEN
,
NUTAG_WITH_THIS_MSG
(
de
->
data
->
e_msg
),
TAG_END
());
forbidden
=
1
;
...
...
@@ -1483,41 +1483,49 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
const
char
*
realm
=
reg_host
;
char
*
url
=
NULL
;
char
*
contact
=
NULL
;
switch_bool_t
update_registration
=
SWITCH_FALSE
;
if
(
auth_params
)
{
username
=
switch_event_get_header
(
auth_params
,
"sip_auth_username"
);
realm
=
switch_event_get_header
(
auth_params
,
"sip_auth_realm"
);
}
if
(
auth_res
!=
AUTH_RENEWED
)
{
if
(
multi_reg
)
{
if
(
multi_reg
)
{
if
(
delete_subs
)
{
if
(
reg_count
==
1
)
{
sql
=
switch_mprintf
(
"update sip_subscriptions set expires=%ld where sip_user='%q' and sip_host='%q' and contact='%q'"
,
(
long
)
switch_epoch_time_now
(
NULL
),
to_user
,
sub_host
,
contact_str
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
if
(
delete_subs
)
{
if
(
reg_count
==
1
)
{
sql
=
switch_mprintf
(
"update sip_subscriptions set expires=%ld where sip_user='%q' and sip_host='%q' and contact='%q'"
,
(
long
)
switch_epoch_time_now
(
NULL
),
to_user
,
sub_host
,
contact_str
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
}
}
if
(
multi_reg_contact
)
{
sql
=
switch_mprintf
(
"delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'"
,
to_user
,
reg_host
,
contact_str
);
if
(
multi_reg_contact
)
{
sql
=
switch_mprintf
(
"delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'"
,
to_user
,
reg_host
,
contact_str
);
}
else
{
sql
=
switch_mprintf
(
"delete from sip_registrations where call_id='%q'"
,
call_id
);
}
}
else
{
sql
=
switch_mprintf
(
"delete from sip_registrations where call_id='%q'"
,
call_id
);
if
(
delete_subs
)
{
sql
=
switch_mprintf
(
"delete from sip_subscriptions where sip_user='%q' and sip_host='%q'"
,
to_user
,
sub_host
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
sql
=
switch_mprintf
(
"delete from sip_registrations where sip_user='%q' and sip_host='%q'"
,
to_user
,
reg_host
);
}
switch_mutex_lock
(
profile
->
ireg_mutex
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
else
{
if
(
delete_subs
)
{
sql
=
switch_mprintf
(
"update sip_subscriptions set expires=%ld where sip_user='%q' and sip_host='%q'"
,
(
long
)
switch_epoch_time_now
(
NULL
),
to_user
,
sub_host
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
char
buf
[
32
]
=
""
;
sql
=
switch_mprintf
(
"select count(*) from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'"
,
to_user
,
reg_host
,
contact_str
);
sofia_glue_execute_sql2str
(
profile
,
profile
->
ireg_mutex
,
sql
,
buf
,
sizeof
(
buf
));
switch_safe_free
(
sql
);
if
(
atoi
(
buf
)
>
0
)
{
update_registration
=
SWITCH_TRUE
;
}
sql
=
switch_mprintf
(
"delete from sip_registrations where sip_user='%q' and sip_host='%q'"
,
to_user
,
reg_host
);
}
switch_mutex_lock
(
profile
->
ireg_mutex
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
switch_find_local_ip
(
guess_ip4
,
sizeof
(
guess_ip4
),
NULL
,
AF_INET
);
...
...
@@ -1530,21 +1538,25 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_safe_free
(
url
);
switch_safe_free
(
contact
);
sql
=
switch_mprintf
(
"insert into sip_registrations "
"(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,"
"user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm,"
"mwi_user,mwi_host, orig_server_host, orig_hostname) "
"values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q')"
,
call_id
,
to_user
,
reg_host
,
profile
->
presence_hosts
?
profile
->
presence_hosts
:
reg_host
,
contact_str
,
reg_desc
,
rpid
,
(
long
)
switch_epoch_time_now
(
NULL
)
+
(
long
)
exptime
+
60
,
agent
,
from_user
,
guess_ip4
,
profile
->
name
,
mod_sofia_globals
.
hostname
,
network_ip
,
network_port_c
,
username
,
realm
,
mwi_user
,
mwi_host
,
guess_ip4
,
mod_sofia_globals
.
hostname
);
if
(
!
update_registration
)
{
sql
=
switch_mprintf
(
"insert into sip_registrations "
"(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,"
"user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm,"
"mwi_user,mwi_host, orig_server_host, orig_hostname) "
"values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q')"
,
call_id
,
to_user
,
reg_host
,
profile
->
presence_hosts
?
profile
->
presence_hosts
:
reg_host
,
contact_str
,
reg_desc
,
rpid
,
(
long
)
switch_epoch_time_now
(
NULL
)
+
(
long
)
exptime
+
60
,
agent
,
from_user
,
guess_ip4
,
profile
->
name
,
mod_sofia_globals
.
hostname
,
network_ip
,
network_port_c
,
username
,
realm
,
mwi_user
,
mwi_host
,
guess_ip4
,
mod_sofia_globals
.
hostname
);
}
else
{
sql
=
switch_mprintf
(
"update sip_registrations set expires = %ld where sip_user='%q' and sip_host='%q' and contact='%q'"
,
(
long
)
switch_epoch_time_now
(
NULL
)
+
(
long
)
exptime
+
60
,
to_user
,
reg_host
,
contact_str
);
}
if
(
sql
)
{
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
if
(
sofia_reg_reg_count
(
profile
,
to_user
,
reg_host
)
==
1
)
{
if
(
!
update_registration
&&
sofia_reg_reg_count
(
profile
,
to_user
,
reg_host
)
==
1
)
{
sql
=
switch_mprintf
(
"delete from sip_presence where sip_user='%q' and sip_host='%q' and profile_name='%q' and open_closed='closed'"
,
to_user
,
reg_host
,
profile
->
name
);
if
(
mod_sofia_globals
.
debug_presence
>
0
)
{
...
...
@@ -2658,8 +2670,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
switch_safe_free
(
input2
);
skip_auth:
if
(
first
&&
ret
==
AUTH_OK
)
{
if
(
first
&&
(
ret
==
AUTH_OK
||
ret
==
AUTH_RENEWED
))
{
if
(
v_event
)
{
switch_event_create_plain
(
v_event
,
SWITCH_EVENT_REQUEST_PARAMS
);
}
...
...
@@ -2785,6 +2796,9 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
switch_assert
(
sql
!=
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
switch_safe_free
(
sql
);
if
(
ret
==
AUTH_OK
)
ret
=
AUTH_RENEWED
;
}
switch_event_destroy
(
&
params
);
...
...
@@ -2804,7 +2818,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
switch_safe_free
(
response
);
if
(
reg_count
&&
!*
reg_count
)
{
if
(
ret
==
AUTH_OK
)
{
if
(
(
ret
==
AUTH_OK
||
ret
==
AUTH_RENEWED
)
)
{
if
(
ncl
)
{
*
reg_count
=
ncl
;
}
else
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论