Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
34c0cbeb
提交
34c0cbeb
authored
1月 17, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3794 ok all testers update to this version and retest
上级
7d4c61a3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
81 行增加
和
38 行删除
+81
-38
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+2
-2
sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_presence.c
+79
-36
没有找到文件。
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
34c0cbeb
...
@@ -5182,8 +5182,8 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
...
@@ -5182,8 +5182,8 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
astate
=
"confirmed"
;
astate
=
"confirmed"
;
}
}
if
(
!
switch_channel_test_flag
(
channel
,
CF_EARLY_MEDIA
)
&&
!
switch_channel_test_flag
(
channel
,
CF_ANSWERED
)
&&
if
(
(
!
switch_channel_test_flag
(
channel
,
CF_EARLY_MEDIA
)
&&
!
switch_channel_test_flag
(
channel
,
CF_ANSWERED
)
&&
!
switch_channel_test_flag
(
channel
,
CF_RING_READY
))
{
!
switch_channel_test_flag
(
channel
,
CF_RING_READY
))
||
sofia_test_flag
(
tech_pvt
,
TFLAG_RECOVERING
))
{
const
char
*
from_user
=
""
,
*
from_host
=
""
,
*
to_user
=
""
,
*
to_host
=
""
,
*
contact_user
=
""
,
*
contact_host
=
""
;
const
char
*
from_user
=
""
,
*
from_host
=
""
,
*
to_user
=
""
,
*
to_host
=
""
,
*
contact_user
=
""
,
*
contact_host
=
""
;
const
char
*
user_agent
=
""
,
*
call_id
=
""
;
const
char
*
user_agent
=
""
,
*
call_id
=
""
;
const
char
*
to_tag
=
""
;
const
char
*
to_tag
=
""
;
...
...
src/mod/endpoints/mod_sofia/sofia_presence.c
浏览文件 @
34c0cbeb
...
@@ -798,7 +798,7 @@ static void do_dialog_probe(sofia_profile_t *profile, switch_event_t *event)
...
@@ -798,7 +798,7 @@ static void do_dialog_probe(sofia_profile_t *profile, switch_event_t *event)
// The dialog_probe_callback has built up the dialogs to be included in the NOTIFY.
// The dialog_probe_callback has built up the dialogs to be included in the NOTIFY.
// Now send the "full" dialog event to the triggering subscription.
// Now send the "full" dialog event to the triggering subscription.
sql
=
switch_mprintf
(
"select call_id,expires,sub_to_user,sub_to_host,event,version, "
sql
=
switch_mprintf
(
"select call_id,expires,sub_to_user,sub_to_host,event,version, "
"'full',full_to,full_from,contact,
expires,event,
network_ip,network_port "
"'full',full_to,full_from,contact,network_ip,network_port "
"from sip_subscriptions "
"from sip_subscriptions "
"where expires > -1 and hostname='%q' "
"where expires > -1 and hostname='%q' "
"and sub_to_user='%q' and sub_to_host='%q' "
"and (event='dialog') and "
"and sub_to_user='%q' and sub_to_host='%q' "
"and (event='dialog') and "
...
@@ -1704,11 +1704,11 @@ static void send_presence_notify(sofia_profile_t *profile,
...
@@ -1704,11 +1704,11 @@ static void send_presence_notify(sofia_profile_t *profile,
nua_handle_bind
(
nh
,
&
mod_sofia_globals
.
destroy_private
);
nua_handle_bind
(
nh
,
&
mod_sofia_globals
.
destroy_private
);
if
(
exptime
<=
0
)
{
if
(
exptime
<=
0
)
{
exptime
=
5
;
switch_snprintf
(
sstr
,
sizeof
(
sstr
),
"terminated;reason=noresource"
);
}
else
{
switch_snprintf
(
sstr
,
sizeof
(
sstr
),
"active;expires=%u"
,
(
unsigned
)
exptime
);
}
}
switch_snprintf
(
sstr
,
sizeof
(
sstr
),
"active;expires=%u"
,
(
unsigned
)
exptime
);
tmp
=
(
char
*
)
contact
;
tmp
=
(
char
*
)
contact
;
contact
=
sofia_glue_get_url_from_contact
(
tmp
,
0
);
contact
=
sofia_glue_get_url_from_contact
(
tmp
,
0
);
...
@@ -2820,7 +2820,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
...
@@ -2820,7 +2820,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
char
*
full_agent
=
NULL
;
char
*
full_agent
=
NULL
;
char
*
sstr
;
char
*
sstr
;
switch_event_t
*
sevent
;
switch_event_t
*
sevent
;
int
sub_state
;
int
sub_state
=
nua_substate_pending
;
int
sent_reply
=
0
;
int
sent_reply
=
0
;
sip_contact_t
const
*
contact
;
sip_contact_t
const
*
contact
;
const
char
*
ipv6
;
const
char
*
ipv6
;
...
@@ -2828,6 +2828,8 @@ void sofia_presence_handle_sip_i_subscribe(int status,
...
@@ -2828,6 +2828,8 @@ void sofia_presence_handle_sip_i_subscribe(int status,
sofia_nat_parse_t
np
=
{
{
0
}
};
sofia_nat_parse_t
np
=
{
{
0
}
};
int
found_proto
=
0
;
int
found_proto
=
0
;
char
to_tag
[
13
]
=
""
;
char
to_tag
[
13
]
=
""
;
char
buf
[
32
]
=
""
;
int
subbed
=
0
;
if
(
!
sip
)
{
if
(
!
sip
)
{
return
;
return
;
...
@@ -2846,7 +2848,17 @@ void sofia_presence_handle_sip_i_subscribe(int status,
...
@@ -2846,7 +2848,17 @@ void sofia_presence_handle_sip_i_subscribe(int status,
//contact_host = sip->sip_contact->m_url->url_host;
//contact_host = sip->sip_contact->m_url->url_host;
contact_user
=
sip
->
sip_contact
->
m_url
->
url_user
;
contact_user
=
sip
->
sip_contact
->
m_url
->
url_user
;
tl_gets
(
tags
,
NUTAG_SUBSTATE_REF
(
sub_state
),
TAG_END
());
//tl_gets(tags, NUTAG_SUBSTATE_REF(sub_state), TAG_END());
//sip->sip_subscription_state->ss_substate
if
(
sip
->
sip_subscription_state
&&
sip
->
sip_subscription_state
->
ss_substate
)
{
if
(
switch_stristr
(
"terminated"
,
sip
->
sip_subscription_state
->
ss_substate
))
{
sub_state
=
nua_substate_terminated
;
}
else
if
(
switch_stristr
(
"active"
,
sip
->
sip_subscription_state
->
ss_substate
))
{
sub_state
=
nua_substate_active
;
}
}
event
=
sip_header_as_string
(
nh
->
nh_home
,
(
void
*
)
sip
->
sip_event
);
event
=
sip_header_as_string
(
nh
->
nh_home
,
(
void
*
)
sip
->
sip_event
);
...
@@ -2877,6 +2889,10 @@ void sofia_presence_handle_sip_i_subscribe(int status,
...
@@ -2877,6 +2889,10 @@ void sofia_presence_handle_sip_i_subscribe(int status,
}
}
}
}
if
(
mod_sofia_globals
.
debug_presence
>
0
||
mod_sofia_globals
.
debug_sla
>
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"DELTA %ld
\n
"
,
exp_delta
);
}
if
(
!
exp_delta
)
{
if
(
!
exp_delta
)
{
sub_state
=
nua_substate_terminated
;
sub_state
=
nua_substate_terminated
;
}
}
...
@@ -2919,6 +2935,18 @@ void sofia_presence_handle_sip_i_subscribe(int status,
...
@@ -2919,6 +2935,18 @@ void sofia_presence_handle_sip_i_subscribe(int status,
proto
=
alt_proto
;
proto
=
alt_proto
;
}
}
sql
=
switch_mprintf
(
"select count(*) from sip_subscriptions where call_id='%q'"
,
call_id
);
sofia_glue_execute_sql2str
(
profile
,
profile
->
ireg_mutex
,
sql
,
buf
,
sizeof
(
buf
));
if
(
mod_sofia_globals
.
debug_presence
>
0
||
mod_sofia_globals
.
debug_sla
>
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"check subs sql: %s [%s]
\n
"
,
sql
,
buf
);
}
if
((
subbed
=
atoi
(
buf
))
>
0
)
{
sub_state
=
nua_substate_active
;
}
if
((
sub_state
==
nua_substate_active
))
{
if
((
sub_state
==
nua_substate_active
))
{
sstr
=
switch_mprintf
(
"active;expires=%ld"
,
exp_delta
);
sstr
=
switch_mprintf
(
"active;expires=%ld"
,
exp_delta
);
...
@@ -2937,23 +2965,12 @@ void sofia_presence_handle_sip_i_subscribe(int status,
...
@@ -2937,23 +2965,12 @@ void sofia_presence_handle_sip_i_subscribe(int status,
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
else
{
}
else
{
#if 0
if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
sql = switch_mprintf("delete from sip_subscriptions where call_id='%q' "
"or (proto='%q' and sip_user='%q' and sip_host='%q' "
"and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q' "
"and contact='%q')",
call_id, proto, from_user, from_host, to_user, to_host, event, mod_sofia_globals.hostname, contact_str);
} else {
sql = switch_mprintf("delete from sip_subscriptions where "
"proto='%q' and sip_user='%q' and sip_host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q'",
proto, from_user, from_host, to_user, to_host, event, mod_sofia_globals.hostname);
}
#endif
sql
=
switch_mprintf
(
"delete from sip_subscriptions where call_id='%q'"
,
call_id
,
mod_sofia_globals
.
hostname
);
sql
=
switch_mprintf
(
"delete from sip_subscriptions where call_id='%q'"
,
call_id
,
mod_sofia_globals
.
hostname
);
if
(
mod_sofia_globals
.
debug_presence
>
0
||
mod_sofia_globals
.
debug_sla
>
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"sub del sql: %s
\n
"
,
sql
);
}
switch_mutex_lock
(
profile
->
ireg_mutex
);
switch_mutex_lock
(
profile
->
ireg_mutex
);
switch_assert
(
sql
!=
NULL
);
switch_assert
(
sql
!=
NULL
);
...
@@ -2965,13 +2982,15 @@ void sofia_presence_handle_sip_i_subscribe(int status,
...
@@ -2965,13 +2982,15 @@ void sofia_presence_handle_sip_i_subscribe(int status,
}
else
{
}
else
{
sip_accept_t
*
ap
=
sip
->
sip_accept
;
sip_accept_t
*
ap
=
sip
->
sip_accept
;
char
accept
[
256
]
=
""
;
char
accept
[
256
]
=
""
;
sub_state
=
nua_substate_active
;
full_agent
=
sip_header_as_string
(
nh
->
nh_home
,
(
void
*
)
sip
->
sip_user_agent
);
full_agent
=
sip_header_as_string
(
nh
->
nh_home
,
(
void
*
)
sip
->
sip_user_agent
);
while
(
ap
)
{
while
(
ap
)
{
switch_snprintf
(
accept
+
strlen
(
accept
),
sizeof
(
accept
)
-
strlen
(
accept
),
"%s%s "
,
ap
->
ac_type
,
ap
->
ac_next
?
","
:
""
);
switch_snprintf
(
accept
+
strlen
(
accept
),
sizeof
(
accept
)
-
strlen
(
accept
),
"%s%s "
,
ap
->
ac_type
,
ap
->
ac_next
?
","
:
""
);
ap
=
ap
->
ac_next
;
ap
=
ap
->
ac_next
;
}
}
sql
=
switch_mprintf
(
"insert into sip_subscriptions "
sql
=
switch_mprintf
(
"insert into sip_subscriptions "
"(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,"
"(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,"
"full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip, orig_proto, full_to) "
"full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip, orig_proto, full_to) "
...
@@ -2984,6 +3003,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
...
@@ -2984,6 +3003,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_assert
(
sql
!=
NULL
);
switch_assert
(
sql
!=
NULL
);
if
(
mod_sofia_globals
.
debug_presence
>
0
||
mod_sofia_globals
.
debug_sla
>
0
)
{
if
(
mod_sofia_globals
.
debug_presence
>
0
||
mod_sofia_globals
.
debug_sla
>
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"%s SUBSCRIBE %s@%s %s@%s
\n
%s
\n
"
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"%s SUBSCRIBE %s@%s %s@%s
\n
%s
\n
"
,
profile
->
name
,
from_user
,
from_host
,
to_user
,
to_host
,
sql
);
profile
->
name
,
from_user
,
from_host
,
to_user
,
to_host
,
sql
);
...
@@ -3333,13 +3353,18 @@ void sofia_presence_handle_sip_r_subscribe(int status,
...
@@ -3333,13 +3353,18 @@ void sofia_presence_handle_sip_r_subscribe(int status,
}
}
}
}
struct
pres_sql_cb
{
sofia_profile_t
*
profile
;
int
ttl
;
};
static
int
sofia_presence_send_sql
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
)
static
int
sofia_presence_send_sql
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
)
{
{
sofia_profile_t
*
profile
=
(
sofia_profile_t
*
)
pArg
;
struct
pres_sql_cb
*
cb
=
(
struct
pres_sql_cb
*
)
pArg
;
send_presence_notify
(
profile
,
argv
[
0
],
argv
[
1
],
argv
[
2
],
argv
[
3
],
argv
[
4
],
argv
[
5
],
argv
[
6
],
argv
[
7
],
argv
[
8
],
argv
[
9
],
NULL
);
send_presence_notify
(
cb
->
profile
,
argv
[
0
],
argv
[
1
],
argv
[
2
],
argv
[
3
],
argv
[
4
],
argv
[
5
],
argv
[
6
],
argv
[
7
],
argv
[
8
],
argv
[
9
],
NULL
);
cb
->
ttl
++
;
return
0
;
return
0
;
}
}
...
@@ -3468,12 +3493,14 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
...
@@ -3468,12 +3493,14 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
}
}
}
else
if
(
contact_str
)
{
}
else
if
(
contact_str
)
{
struct
pres_sql_cb
cb
=
{
profile
,
0
};
sql
=
switch_mprintf
(
"select full_to, full_from, contact, expires, call_id, event, network_ip, network_port, "
sql
=
switch_mprintf
(
"select full_to, full_from, contact, expires, call_id, event, network_ip, network_port, "
"'application/pidf+xml' as ct,'%q' as pt "
"'application/pidf+xml' as ct,'%q' as pt "
" from sip_subscriptions where sub_to_user='%q' and sub_to_host='%q' and event='%q'"
" from sip_subscriptions where sub_to_user='%q' and sub_to_host='%q' and event='%q'"
"and contact = '%q' "
,
switch_str_nil
(
payload
->
pl_data
),
from_user
,
from_host
,
event_type
);
"and contact = '%q' "
,
switch_str_nil
(
payload
->
pl_data
),
from_user
,
from_host
,
event_type
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_presence_send_sql
,
profile
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_presence_send_sql
,
&
cb
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
}
}
...
@@ -3701,20 +3728,36 @@ void sofia_presence_check_subscriptions(sofia_profile_t *profile, time_t now)
...
@@ -3701,20 +3728,36 @@ void sofia_presence_check_subscriptions(sofia_profile_t *profile, time_t now)
char
*
sql
;
char
*
sql
;
if
(
now
)
{
if
(
now
)
{
struct
pres_sql_cb
cb
=
{
profile
,
0
};
#if 0 // I think actually doing it right and sending terminated notify breaks dumb phones.
if
(
profile
->
pres_type
!=
PRES_TYPE_FULL
)
{
sql = switch_mprintf("select full_to, full_from, contact, expires, call_id, event, network_ip, network_port, "
if
(
mod_sofia_globals
.
debug_presence
>
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"check_subs: %s is passive, skipping
\n
"
,
(
char
*
)
profile
->
name
);
}
return
;
}
sql
=
switch_mprintf
(
"select full_to, full_from, contact, -1, call_id, event, network_ip, network_port, "
"NULL as ct, NULL as pt "
"NULL as ct, NULL as pt "
" from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%q'",
" from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and
profile_name='%q' and
hostname='%q'"
,
(long) now, mod_sofia_globals.hostname);
(
long
)
now
,
profile
->
name
,
mod_sofia_globals
.
hostname
);
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_send_sql,
profile
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_presence_send_sql
,
&
cb
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
#endif
sql
=
switch_mprintf
(
"delete from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%q'"
,
if
(
cb
.
ttl
)
{
(
long
)
now
,
mod_sofia_globals
.
hostname
);
sql
=
switch_mprintf
(
"delete from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) "
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
"and profile_name='%q' and hostname='%q'"
,
(
long
)
now
,
profile
->
name
,
mod_sofia_globals
.
hostname
);
if
(
mod_sofia_globals
.
debug_presence
>
0
||
mod_sofia_globals
.
debug_sla
>
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"sub del sql: %s
\n
"
,
sql
);
}
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论