Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
belle-sip
Commits
e3edcea8
Commit
e3edcea8
authored
Feb 17, 2014
by
Simon Morlat
Browse files
add new test to verify SRV/IP failover mechanism of channels
parent
cb977e6a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
11 deletions
+30
-11
include/belle-sip/transaction.h
include/belle-sip/transaction.h
+2
-0
src/belle_sip_loop.c
src/belle_sip_loop.c
+1
-0
src/channel.c
src/channel.c
+7
-3
src/transaction.c
src/transaction.c
+4
-0
src/transports/stream_channel.c
src/transports/stream_channel.c
+2
-6
tester/belle_sip_register_tester.c
tester/belle_sip_register_tester.c
+14
-2
No files found.
include/belle-sip/transaction.h
View file @
e3edcea8
...
...
@@ -66,6 +66,8 @@ BELLESIP_EXPORT int belle_sip_client_transaction_send_request(belle_sip_client_t
* */
BELLESIP_EXPORT
int
belle_sip_client_transaction_send_request_to
(
belle_sip_client_transaction_t
*
t
,
belle_sip_uri_t
*
outbound_proxy
);
BELLESIP_EXPORT
belle_sip_uri_t
*
belle_sip_client_transaction_get_route
(
belle_sip_client_transaction_t
*
t
);
/**
* Creates an a sip refresher for transaction like REGISTER/SUBSCRIBE or INVITE which could be refreshed.
* Transaction must in be in stated BELLE_SIP_TRANSACTION_COMPLETED. Refresher is created and started. A ref is taken on object transaction
...
...
src/belle_sip_loop.c
View file @
e3edcea8
...
...
@@ -280,6 +280,7 @@ void belle_sip_main_loop_add_source(belle_sip_main_loop_t *ml, belle_sip_source_
if
(
source
->
timeout
>=
0
){
source
->
expire_ms
=
belle_sip_time_ms
()
+
source
->
timeout
;
}
source
->
cancelled
=
FALSE
;
ml
->
sources
=
belle_sip_list_append_link
(
ml
->
sources
,
&
source
->
node
);
ml
->
nsources
++
;
}
...
...
src/channel.c
View file @
e3edcea8
...
...
@@ -667,6 +667,11 @@ static void channel_invoke_state_listener_defered(belle_sip_channel_t *obj){
belle_sip_object_unref
(
obj
);
}
static
void
channel_connect_next
(
belle_sip_channel_t
*
obj
){
belle_sip_channel_connect
(
obj
);
belle_sip_object_unref
(
obj
);
}
static
void
belle_sip_channel_handle_error
(
belle_sip_channel_t
*
obj
){
if
(
obj
->
state
!=
BELLE_SIP_CHANNEL_READY
){
/* Previous connection attempts were failed (channel could not get ready).*/
...
...
@@ -675,7 +680,7 @@ static void belle_sip_channel_handle_error(belle_sip_channel_t *obj){
obj
->
current_peer
=
obj
->
current_peer
->
ai_next
;
channel_set_state
(
obj
,
BELLE_SIP_CHANNEL_RETRY
);
belle_sip_channel_close
(
obj
);
belle_sip_
channel_connect
(
obj
);
belle_sip_
main_loop_do_later
(
obj
->
stack
->
ml
,(
belle_sip_callback_t
)
channel_connect_next
,
belle_sip_object_ref
(
obj
)
)
;
return
;
}
/*else we have already tried all the ip addresses, so give up and notify the error*/
}
/*else the channel was previously working good with the current ip address but now fails, so let's notify the error*/
...
...
@@ -685,8 +690,7 @@ static void belle_sip_channel_handle_error(belle_sip_channel_t *obj){
* it is safer to invoke the listener outside the current call stack.
* Indeed the channel encounters network errors while being called for transmiting by a transaction.
*/
belle_sip_object_ref
(
obj
);
belle_sip_main_loop_do_later
(
obj
->
stack
->
ml
,(
belle_sip_callback_t
)
channel_invoke_state_listener_defered
,
obj
);
belle_sip_main_loop_do_later
(
obj
->
stack
->
ml
,(
belle_sip_callback_t
)
channel_invoke_state_listener_defered
,
belle_sip_object_ref
(
obj
));
}
int
belle_sip_channel_notify_timeout
(
belle_sip_channel_t
*
obj
){
...
...
src/transaction.c
View file @
e3edcea8
...
...
@@ -456,6 +456,10 @@ void belle_sip_client_transaction_add_response(belle_sip_client_transaction_t *t
BELLE_SIP_OBJECT_VPTR
(
t
,
belle_sip_client_transaction_t
)
->
on_response
(
t
,
resp
);
}
belle_sip_uri_t
*
belle_sip_client_transaction_get_route
(
belle_sip_client_transaction_t
*
t
){
return
t
->
preset_route
;
}
static
void
client_transaction_destroy
(
belle_sip_client_transaction_t
*
t
){
if
(
t
->
preset_route
)
belle_sip_object_unref
(
t
->
preset_route
);
if
(
t
->
next_hop
)
belle_sip_object_unref
(
t
->
next_hop
);
...
...
src/transports/stream_channel.c
View file @
e3edcea8
...
...
@@ -170,15 +170,11 @@ int finalize_stream_connection(belle_sip_stream_channel_t *obj, unsigned int rev
socklen_t
optlen
=
sizeof
(
errnum
);
belle_sip_socket_t
sock
=
belle_sip_source_get_socket
((
belle_sip_source_t
*
)
obj
);
if
(
revents
&
BELLE_SIP_EVENT_READ
){
belle_sip_warning
(
"channel [%p]: getting read event while connecting"
,
obj
);
return
-
1
;
}
if
(
revents
==
BELLE_SIP_EVENT_TIMEOUT
){
belle_sip_warning
(
"channel [%p]: user-defined transport timeout."
,
obj
);
return
-
1
;
}
if
(
!
(
revents
&
BELLE_SIP_EVENT_WRITE
)){
if
(
!
(
revents
&
BELLE_SIP_EVENT_WRITE
)
&&
!
(
revents
&
BELLE_SIP_EVENT_READ
)
){
belle_sip_warning
(
"channel [%p]: getting unexpected event while connecting"
,
obj
);
return
-
1
;
}
...
...
@@ -215,7 +211,7 @@ static int stream_channel_process_data(belle_sip_stream_channel_t *obj,unsigned
belle_sip_channel_state_t
state
=
belle_sip_channel_get_state
((
belle_sip_channel_t
*
)
obj
);
belle_sip_channel_t
*
base
=
(
belle_sip_channel_t
*
)
obj
;
belle_sip_message
(
"TCP channel process_data"
);
/*
belle_sip_message("TCP channel process_data");
*/
if
(
state
==
BELLE_SIP_CHANNEL_CONNECTING
)
{
if
(
finalize_stream_connection
(
obj
,
revents
,(
struct
sockaddr
*
)
&
ss
,
&
addrlen
))
{
...
...
tester/belle_sip_register_tester.c
View file @
e3edcea8
...
...
@@ -78,14 +78,17 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even
if
(
status
==
401
)
{
belle_sip_header_cseq_t
*
cseq
;
belle_sip_client_transaction_t
*
t
;
belle_sip_uri_t
*
dest
;
CU_ASSERT_NOT_EQUAL_FATAL
(
number_of_challenge
,
2
);
CU_ASSERT_PTR_NOT_NULL_FATAL
(
belle_sip_response_event_get_client_transaction
(
event
));
/*require transaction mode*/
dest
=
belle_sip_client_transaction_get_route
(
belle_sip_response_event_get_client_transaction
(
event
));
request
=
belle_sip_transaction_get_request
(
BELLE_SIP_TRANSACTION
(
belle_sip_response_event_get_client_transaction
(
event
)));
cseq
=
(
belle_sip_header_cseq_t
*
)
belle_sip_message_get_header
(
BELLE_SIP_MESSAGE
(
request
),
BELLE_SIP_CSEQ
);
belle_sip_header_cseq_set_seq_number
(
cseq
,
belle_sip_header_cseq_get_seq_number
(
cseq
)
+
1
);
CU_ASSERT_TRUE_FATAL
(
belle_sip_provider_add_authorization
(
prov
,
request
,
belle_sip_response_event_get_response
(
event
),
NULL
));
t
=
belle_sip_provider_create_client_transaction
(
prov
,
request
);
belle_sip_client_transaction_send_request
(
t
);
belle_sip_client_transaction_send_request
_to
(
t
,
des
t
);
number_of_challenge
++
;
authorized_request
=
request
;
belle_sip_object_ref
(
authorized_request
);
...
...
@@ -517,6 +520,14 @@ static void test_tls_to_tcp(void){
belle_sip_stack_set_transport_timeout
(
stack
,
orig
);
}
static
void
register_dns_srv
(
void
){
belle_sip_request_t
*
req
;
io_error_count
=
0
;
req
=
try_register_user_at_domain
(
stack
,
prov
,
"TCP"
,
1
,
"tester"
,
client_auth_domain
,
"sip:linphone.net;transport=tcp"
,
1
);
CU_ASSERT_TRUE
(
io_error_count
==
0
);
if
(
req
)
belle_sip_object_unref
(
req
);
}
test_t
register_tests
[]
=
{
{
"Stateful UDP"
,
stateful_register_udp
},
{
"Stateful UDP with keep-alive"
,
stateful_register_udp_with_keep_alive
},
...
...
@@ -534,7 +545,8 @@ test_t register_tests[] = {
{
"Channel inactive"
,
test_register_channel_inactive
},
{
"TCP connection failure"
,
test_connection_failure
},
{
"TCP connection too long"
,
test_connection_too_long
},
{
"TLS connection to TCP server"
,
test_tls_to_tcp
}
{
"TLS connection to TCP server"
,
test_tls_to_tcp
},
{
"Register with DNS SRV failover"
,
register_dns_srv
}
};
test_suite_t
register_test_suite
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment