]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Limit maximum number of stored P2P clients to 100
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 23 Aug 2012 21:23:44 +0000 (00:23 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 23 Aug 2012 21:25:14 +0000 (00:25 +0300)
This limits the maximum size of the p2p_client_list parameter that
is maintained at the GO for a persistent group. In other words, only
the 100 most recently seen P2P clients are kept in the list.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
intended-for: hostap-1

wpa_supplicant/config_ssid.h
wpa_supplicant/p2p_supplicant.c

index 476a98492e1d80c63e612cd1ead13f30481df956..232c9c0d0b6ec2393c54d64e6671342aade3a534 100644 (file)
@@ -431,6 +431,10 @@ struct wpa_ssid {
         */
        size_t num_p2p_clients;
 
+#ifndef P2P_MAX_STORED_CLIENTS
+#define P2P_MAX_STORED_CLIENTS 100
+#endif /* P2P_MAX_STORED_CLIENTS */
+
        /**
         * p2p_group - Network generated as a P2P group (used internally)
         */
index cf4b3f21b1efb25a6d5e9bd9e8a0aeaf7ebc3531..32b7b44889f39141e81ecae28056ee93d497d4b9 100644 (file)
@@ -560,7 +560,7 @@ static void wpas_p2p_add_persistent_group_client(struct wpa_supplicant *wpa_s,
                break;
        }
 
-       if (!found) {
+       if (!found && s->num_p2p_clients < P2P_MAX_STORED_CLIENTS) {
                n = os_realloc_array(s->p2p_client_list,
                                     s->num_p2p_clients + 1, ETH_ALEN);
                if (n == NULL)
@@ -568,6 +568,15 @@ static void wpas_p2p_add_persistent_group_client(struct wpa_supplicant *wpa_s,
                os_memcpy(n + s->num_p2p_clients * ETH_ALEN, addr, ETH_ALEN);
                s->p2p_client_list = n;
                s->num_p2p_clients++;
+       } else if (!found) {
+               /* Not enough room for an additional entry - drop the oldest
+                * entry */
+               os_memmove(s->p2p_client_list,
+                          s->p2p_client_list + ETH_ALEN,
+                          (s->num_p2p_clients - 1) * ETH_ALEN);
+               os_memcpy(s->p2p_client_list +
+                         (s->num_p2p_clients - 1) * ETH_ALEN,
+                         addr, ETH_ALEN);
        }
 
 #ifndef CONFIG_NO_CONFIG_WRITE