Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
b8483f6c
Commit
b8483f6c
authored
Dec 17, 2010
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not loop forever if we keep getting unauthorized error on create_permission
parent
873418ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
24 deletions
+45
-24
socket/turn.c
socket/turn.c
+45
-24
No files found.
socket/turn.c
View file @
b8483f6c
...
@@ -125,11 +125,9 @@ static gboolean priv_retransmissions_tick_unlocked (TurnPriv *priv);
...
@@ -125,11 +125,9 @@ static gboolean priv_retransmissions_tick_unlocked (TurnPriv *priv);
static
gboolean
priv_retransmissions_tick
(
gpointer
pointer
);
static
gboolean
priv_retransmissions_tick
(
gpointer
pointer
);
static
void
priv_schedule_tick
(
TurnPriv
*
priv
);
static
void
priv_schedule_tick
(
TurnPriv
*
priv
);
static
void
priv_send_turn_message
(
TurnPriv
*
priv
,
TURNMessage
*
msg
);
static
void
priv_send_turn_message
(
TurnPriv
*
priv
,
TURNMessage
*
msg
);
static
gboolean
priv_send_create_permission
(
TurnPriv
*
priv
,
static
gboolean
priv_send_create_permission
(
TurnPriv
*
priv
,
StunMessage
*
resp
,
uint8_t
*
realm
,
gsize
realm_len
,
uint8_t
*
nonce
,
gsize
nonce_len
,
const
NiceAddress
*
peer
);
const
NiceAddress
*
peer
);
static
gboolean
priv_send_channel_bind
(
TurnPriv
*
priv
,
StunMessage
*
resp
,
static
gboolean
priv_send_channel_bind
(
TurnPriv
*
priv
,
StunMessage
*
resp
,
uint16_t
channel
,
uint16_t
channel
,
const
NiceAddress
*
peer
);
const
NiceAddress
*
peer
);
static
gboolean
priv_add_channel_binding
(
TurnPriv
*
priv
,
static
gboolean
priv_add_channel_binding
(
TurnPriv
*
priv
,
...
@@ -564,7 +562,7 @@ socket_send (NiceSocket *sock, const NiceAddress *to,
...
@@ -564,7 +562,7 @@ socket_send (NiceSocket *sock, const NiceAddress *to,
if
(
priv
->
compatibility
==
NICE_TURN_SOCKET_COMPATIBILITY_RFC5766
&&
if
(
priv
->
compatibility
==
NICE_TURN_SOCKET_COMPATIBILITY_RFC5766
&&
!
priv_has_permission_for_peer
(
priv
,
to
))
{
!
priv_has_permission_for_peer
(
priv
,
to
))
{
if
(
!
priv_has_sent_permission_for_peer
(
priv
,
to
))
{
if
(
!
priv_has_sent_permission_for_peer
(
priv
,
to
))
{
priv_send_create_permission
(
priv
,
NULL
,
0
,
NULL
,
0
,
to
);
priv_send_create_permission
(
priv
,
NULL
,
to
);
}
}
/* enque data */
/* enque data */
...
@@ -929,7 +927,6 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
...
@@ -929,7 +927,6 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
sizeof
(
StunTransactionId
))
==
0
)
{
sizeof
(
StunTransactionId
))
==
0
)
{
struct
sockaddr
peer
;
struct
sockaddr
peer
;
socklen_t
peer_len
=
sizeof
(
peer
);
socklen_t
peer_len
=
sizeof
(
peer
);
int
code
=
-
1
;
NiceAddress
to
;
NiceAddress
to
;
nice_debug
(
"got response for CreatePermission"
);
nice_debug
(
"got response for CreatePermission"
);
...
@@ -942,26 +939,42 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
...
@@ -942,26 +939,42 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
g_free
(
priv
->
current_create_permission_msg
);
g_free
(
priv
->
current_create_permission_msg
);
priv
->
current_create_permission_msg
=
NULL
;
priv
->
current_create_permission_msg
=
NULL
;
/* unathorized => resend with realm and nonce) */
/* unathorized => resend with realm and nonce */
if
(
stun_message_get_class
(
&
msg
)
==
STUN_ERROR
&&
if
(
stun_message_get_class
(
&
msg
)
==
STUN_ERROR
)
{
stun_message_find_error
(
&
msg
,
&
code
)
==
int
code
=
-
1
;
STUN_MESSAGE_RETURN_SUCCESS
&&
uint8_t
*
sent_realm
=
NULL
;
(
code
==
438
||
(
code
==
401
)))
{
uint8_t
*
recv_realm
=
NULL
;
uint8_t
*
recv_realm
=
NULL
;
uint16_t
sent_realm_len
=
0
;
uint16_t
recv_realm_len
=
0
;
uint16_t
recv_realm_len
=
0
;
uint8_t
*
recv_nonce
=
NULL
;
uint16_t
recv_nonce_len
=
0
;
recv_realm
=
(
uint8_t
*
)
stun_message_find
(
&
msg
,
sent_realm
=
STUN_ATTRIBUTE_REALM
,
&
recv_realm_len
);
(
uint8_t
*
)
stun_message_find
(
recv_nonce
=
(
uint8_t
*
)
stun_message_find
(
&
msg
,
&
priv
->
current_create_permission_msg
->
message
,
STUN_ATTRIBUTE_NONCE
,
&
recv_nonce_len
);
STUN_ATTRIBUTE_REALM
,
&
sent_realm_len
);
recv_realm
=
(
uint8_t
*
)
stun_message_find
(
&
msg
,
STUN_ATTRIBUTE_REALM
,
&
recv_realm_len
);
/* resend CreatePermission */
/* check for unauthorized error response */
priv_send_create_permission
(
priv
,
recv_realm
,
recv_realm_len
,
if
(
stun_message_find_error
(
&
msg
,
&
code
)
==
recv_nonce
,
recv_nonce_len
,
&
to
);
STUN_MESSAGE_RETURN_SUCCESS
&&
}
else
{
(
code
==
438
||
(
code
==
401
&&
/* we now have a permission installed for this peer */
!
(
recv_realm
!=
NULL
&&
recv_realm_len
>
0
&&
recv_realm_len
==
sent_realm_len
&&
sent_realm
!=
NULL
&&
memcmp
(
sent_realm
,
recv_realm
,
sent_realm_len
)
==
0
))))
{
g_free
(
priv
->
current_create_permission_msg
);
priv
->
current_create_permission_msg
=
NULL
;
/* resend CreatePermission */
priv_send_create_permission
(
priv
,
&
msg
,
&
to
);
return
0
;
}
/* If we get an error, we just assume the server somehow
doesn't support permissions and we ignore the error and
fake a successful completion. If the server needs a permission
but it failed to create it, then the connchecks will fail. */
priv_remove_sent_permission_for_peer
(
priv
,
&
to
);
priv_remove_sent_permission_for_peer
(
priv
,
&
to
);
priv_add_permission_for_peer
(
priv
,
&
to
);
priv_add_permission_for_peer
(
priv
,
&
to
);
...
@@ -1300,14 +1313,22 @@ priv_send_turn_message (TurnPriv *priv, TURNMessage *msg)
...
@@ -1300,14 +1313,22 @@ priv_send_turn_message (TurnPriv *priv, TURNMessage *msg)
}
}
static
gboolean
static
gboolean
priv_send_create_permission
(
TurnPriv
*
priv
,
uint8_t
*
realm
,
gsize
realm_len
,
priv_send_create_permission
(
TurnPriv
*
priv
,
StunMessage
*
resp
,
uint8_t
*
nonce
,
gsize
nonce_len
,
const
NiceAddress
*
peer
)
const
NiceAddress
*
peer
)
{
{
guint
msg_buf_len
;
guint
msg_buf_len
;
gboolean
res
=
FALSE
;
gboolean
res
=
FALSE
;
TURNMessage
*
msg
=
g_new0
(
TURNMessage
,
1
);
TURNMessage
*
msg
=
g_new0
(
TURNMessage
,
1
);
struct
sockaddr
addr
;
struct
sockaddr
addr
;
uint8_t
*
realm
=
NULL
;
uint16_t
realm_len
=
0
;
uint8_t
*
nonce
=
NULL
;
uint16_t
nonce_len
=
0
;
realm
=
(
uint8_t
*
)
stun_message_find
(
resp
,
STUN_ATTRIBUTE_REALM
,
&
realm_len
);
nonce
=
(
uint8_t
*
)
stun_message_find
(
resp
,
STUN_ATTRIBUTE_NONCE
,
&
nonce_len
);
/* register this peer as being pening a permission (if not already pending) */
/* register this peer as being pening a permission (if not already pending) */
if
(
!
priv_has_sent_permission_for_peer
(
priv
,
peer
))
{
if
(
!
priv_has_sent_permission_for_peer
(
priv
,
peer
))
{
...
...
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