Find friend by port.
[cascardo/f2fchat.git] / friend.c
index 2d317e7..fd79643 100644 (file)
--- a/friend.c
+++ b/friend.c
@@ -62,12 +62,13 @@ struct cache {
 
 static struct cache *ucache;
 
-struct friend *friend_get_by_address(GInetAddress *address)
+struct friend *friend_get_by_address(GInetAddress *address, uint16_t port)
 {
        GList *l;
        for (l = g_list_first(ucache->friends); l != NULL; l = g_list_next(l)) {
                struct friend *friend = l->data;
-               if (g_inet_address_equal(g_inet_socket_address_get_address(friend->saddr), address))
+               if (g_inet_address_equal(g_inet_socket_address_get_address(friend->saddr), address) &&
+                   friend->port == port)
                        return friend;
        }
        return NULL;