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
mediastreamer2
Commits
d5f95918
Commit
d5f95918
authored
Aug 06, 2012
by
Ghislain MARY
Browse files
Use the same STUN transaction ID for retransmissions of STUN requests for ICE candidates gathering.
parent
e3709d71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
include/mediastreamer2/ice.h
include/mediastreamer2/ice.h
+1
-0
src/ice.c
src/ice.c
+11
-4
No files found.
include/mediastreamer2/ice.h
View file @
d5f95918
...
...
@@ -115,6 +115,7 @@ typedef struct _IceSession {
typedef
struct
_IceStunServerCheck
{
ortp_socket_t
sock
;
UInt96
transactionID
;
uint64_t
transmission_time
;
uint8_t
nb_transmissions
;
}
IceStunServerCheck
;
...
...
src/ice.c
View file @
d5f95918
...
...
@@ -107,7 +107,7 @@ typedef struct _Session_Index {
extern
void
rtp_session_dispatch_event
(
RtpSession
*
session
,
OrtpEvent
*
ev
);
static
void
ice_send_stun_server_binding_request
(
ortp_socket_t
sock
,
const
struct
sockaddr
*
server
,
socklen_t
addrlen
,
int
id
);
static
void
ice_send_stun_server_binding_request
(
ortp_socket_t
sock
,
const
struct
sockaddr
*
server
,
socklen_t
addrlen
,
UInt96
*
transactionID
,
uint8_t
nb_transmissions
,
int
id
);
static
int
ice_compare_transport_addresses
(
const
IceTransportAddress
*
ta1
,
const
IceTransportAddress
*
ta2
);
static
int
ice_compare_pair_priorities
(
const
IceCandidatePair
*
p1
,
const
IceCandidatePair
*
p2
);
static
int
ice_compare_pairs
(
const
IceCandidatePair
*
p1
,
const
IceCandidatePair
*
p2
);
...
...
@@ -695,7 +695,8 @@ static void ice_check_list_gather_candidates(IceCheckList *cl, Session_Index *si
if
(
si
->
index
==
0
)
{
check
->
transmission_time
=
curtime
+
ICE_DEFAULT_RTO_DURATION
;
check
->
nb_transmissions
=
1
;
ice_send_stun_server_binding_request
(
sock
,
(
struct
sockaddr
*
)
&
cl
->
session
->
ss
,
cl
->
session
->
ss_len
,
check
->
sock
);
ice_send_stun_server_binding_request
(
sock
,
(
struct
sockaddr
*
)
&
cl
->
session
->
ss
,
cl
->
session
->
ss_len
,
&
check
->
transactionID
,
check
->
nb_transmissions
,
check
->
sock
);
}
else
{
check
->
transmission_time
=
curtime
+
2
*
si
->
index
*
ICE_DEFAULT_TA_DURATION
;
}
...
...
@@ -727,7 +728,7 @@ void ice_session_gather_candidates(IceSession *session, struct sockaddr_storage
* STUN PACKETS HANDLING *
*****************************************************************************/
static
void
ice_send_stun_server_binding_request
(
ortp_socket_t
sock
,
const
struct
sockaddr
*
server
,
socklen_t
addrlen
,
int
id
)
static
void
ice_send_stun_server_binding_request
(
ortp_socket_t
sock
,
const
struct
sockaddr
*
server
,
socklen_t
addrlen
,
UInt96
*
transactionID
,
uint8_t
nb_transmissions
,
int
id
)
{
StunMessage
msg
;
StunAtrString
username
;
...
...
@@ -740,9 +741,14 @@ static void ice_send_stun_server_binding_request(ortp_socket_t sock, const struc
memset
(
&
username
,
0
,
sizeof
(
username
));
memset
(
&
password
,
0
,
sizeof
(
password
));
stunBuildReqSimple
(
&
msg
,
&
username
,
FALSE
,
FALSE
,
id
);
if
(
nb_transmissions
>
1
)
{
/* Keep the same transaction ID for retransmissions. */
memcpy
(
&
msg
.
msgHdr
.
tr_id
,
transactionID
,
sizeof
(
msg
.
msgHdr
.
tr_id
));
}
len
=
stunEncodeMessage
(
&
msg
,
buf
,
len
,
&
password
);
if
(
len
>
0
)
{
sendMessage
(
sock
,
buf
,
len
,
htonl
(
servaddr
->
sin_addr
.
s_addr
),
htons
(
servaddr
->
sin_port
));
memcpy
(
transactionID
,
&
msg
.
msgHdr
.
tr_id
,
sizeof
(
*
transactionID
));
}
}
...
...
@@ -2310,7 +2316,8 @@ static void ice_send_stun_server_checks(IceStunServerCheck *check, IceCheckList
check
->
nb_transmissions
++
;
if
(
check
->
nb_transmissions
<=
ICE_MAX_RETRANSMISSIONS
)
{
check
->
transmission_time
=
curtime
+
ICE_DEFAULT_RTO_DURATION
;
ice_send_stun_server_binding_request
(
check
->
sock
,
(
struct
sockaddr
*
)
&
cl
->
session
->
ss
,
cl
->
session
->
ss_len
,
check
->
sock
);
ice_send_stun_server_binding_request
(
check
->
sock
,
(
struct
sockaddr
*
)
&
cl
->
session
->
ss
,
cl
->
session
->
ss_len
,
&
check
->
transactionID
,
check
->
nb_transmissions
,
check
->
sock
);
}
}
}
...
...
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