Commit ecca7064 authored by Marcus Lundblad's avatar Marcus Lundblad Committed by Youness Alaoui

OK, so nice_address_equal does not fullfill GCompareFunc, use custom lookup functions

parent fe6ac77f
...@@ -337,17 +337,31 @@ stun_message_ensure_ms_realm(StunMessage *msg, uint8_t *realm) ...@@ -337,17 +337,31 @@ stun_message_ensure_ms_realm(StunMessage *msg, uint8_t *realm)
static gboolean static gboolean
priv_has_permission_for_peer (TurnPriv *priv, const NiceAddress *to) priv_has_permission_for_peer (TurnPriv *priv, const NiceAddress *to)
{ {
GList *found = g_list_find_custom (priv->permissions, to, GList *iter;
(GCompareFunc) nice_address_equal);
for (iter = priv->permissions ; iter ; iter = g_list_next (iter)) {
NiceAddress *address = (NiceAddress *) iter->data;
if (nice_address_equal (address, to))
return TRUE;
}
return found != NULL; return FALSE;
} }
static gboolean static gboolean
priv_has_sent_permission_for_peer (TurnPriv *priv, const NiceAddress *to) priv_has_sent_permission_for_peer (TurnPriv *priv, const NiceAddress *to)
{ {
return g_list_find_custom (priv->sent_permissions, to, GList *iter;
(GCompareFunc) nice_address_equal) != NULL;
for (iter = priv->sent_permissions ; iter ; iter = g_list_next (iter)) {
NiceAddress *address = (NiceAddress *) iter->data;
if (nice_address_equal (address, to))
return TRUE;
}
return FALSE;
} }
static void static void
...@@ -830,19 +844,22 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock, ...@@ -830,19 +844,22 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
nice_address_free (to); nice_address_free (to);
} else { } else {
/* we now have a permission installed for this peer */ /* we now have a permission installed for this peer */
GList *sent_permission = GList *iter;
g_list_find_custom (priv->sent_permissions, to,
(GCompareFunc) nice_address_equal);
priv->permissions = for (iter = priv->sent_permissions ; iter ; iter = g_list_next (iter)) {
g_list_append (priv->permissions, to); NiceAddress *address = (NiceAddress *) iter->data;
if (sent_permission) { if (nice_address_equal (address, to)) {
nice_address_free ((NiceAddress *) sent_permission->data); nice_address_free ((NiceAddress *) iter->data);
priv->sent_permissions = priv->sent_permissions =
g_list_remove_link (priv->sent_permissions, sent_permission); g_list_remove_link (priv->sent_permissions, iter);
break;
}
} }
priv->permissions =
g_list_append (priv->permissions, to);
/* install timer to schedule refresh of the permission */ /* install timer to schedule refresh of the permission */
/* (will not schedule refresh if we got an error) */ /* (will not schedule refresh if we got an error) */
if (stun_message_get_class (&msg) == STUN_RESPONSE && if (stun_message_get_class (&msg) == STUN_RESPONSE &&
...@@ -1178,8 +1195,10 @@ priv_send_create_permission(TurnPriv *priv, uint8_t *realm, gsize realm_len, ...@@ -1178,8 +1195,10 @@ priv_send_create_permission(TurnPriv *priv, uint8_t *realm, gsize realm_len,
TURNMessage *msg = g_new0 (TURNMessage, 1); TURNMessage *msg = g_new0 (TURNMessage, 1);
struct sockaddr addr; struct sockaddr addr;
NiceAddress *to = nice_address_dup (peer); NiceAddress *to = nice_address_dup (peer);
gchar addr_str[NICE_ADDRESS_STRING_LEN];
nice_debug("creating CreatePermission message"); nice_address_to_string (to, addr_str);
nice_debug("creating CreatePermission message for %s", addr_str);
priv->sent_permissions = g_list_append (priv->sent_permissions, to); priv->sent_permissions = g_list_append (priv->sent_permissions, to);
nice_address_copy_to_sockaddr (peer, &addr); nice_address_copy_to_sockaddr (peer, &addr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment