P2P: Add wpas_p2p_disconnect()
authorJohannes Berg <johannes.berg@intel.com>
Wed, 2 Feb 2011 15:30:15 +0000 (17:30 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 2 Feb 2011 15:30:15 +0000 (17:30 +0200)
Add a new API function wpas_p2p_disconnect()
to disconnect from or dissolve a group.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h

index bcd28c4..dfc50c5 100644 (file)
@@ -3034,8 +3034,7 @@ int wpas_p2p_group_remove(struct wpa_supplicant *wpa_s, const char *ifname)
                while (wpa_s) {
                        prev = wpa_s;
                        wpa_s = wpa_s->next;
-                       prev->removal_reason = P2P_GROUP_REMOVAL_REQUESTED;
-                       wpas_p2p_group_delete(prev);
+                       wpas_p2p_disconnect(prev);
                }
                return 0;
        }
@@ -3045,13 +3044,7 @@ int wpas_p2p_group_remove(struct wpa_supplicant *wpa_s, const char *ifname)
                        break;
        }
 
-       if (wpa_s == NULL)
-               return -1;
-
-       wpa_s->removal_reason = P2P_GROUP_REMOVAL_REQUESTED;
-       wpas_p2p_group_delete(wpa_s);
-
-       return 0;
+       return wpas_p2p_disconnect(wpa_s);
 }
 
 
@@ -4156,3 +4149,27 @@ int wpas_p2p_unauthorize(struct wpa_supplicant *wpa_s, const char *addr)
 
        return p2p_unauthorize(p2p, peer);
 }
+
+
+/**
+ * wpas_p2p_disconnect - Disconnect from a P2P Group
+ * @wpa_s: Pointer to wpa_supplicant data
+ * Returns: 0 on success, -1 on failure
+ *
+ * This can be used to disconnect from a group in which the local end is a P2P
+ * Client or to end a P2P Group in case the local end is the Group Owner. If a
+ * virtual network interface was created for this group, that interface will be
+ * removed. Otherwise, only the configured P2P group network will be removed
+ * from the interface.
+ */
+int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s)
+{
+
+       if (wpa_s == NULL)
+               return -1;
+
+       wpa_s->removal_reason = P2P_GROUP_REMOVAL_REQUESTED;
+       wpas_p2p_group_delete(wpa_s);
+
+       return 0;
+}
index 7f59453..7959a25 100644 (file)
@@ -121,5 +121,6 @@ void wpas_p2p_interface_unavailable(struct wpa_supplicant *wpa_s);
 void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
                                   int freq_24, int freq_5, int freq_overall);
 int wpas_p2p_unauthorize(struct wpa_supplicant *wpa_s, const char *addr);
+int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s);
 
 #endif /* P2P_SUPPLICANT_H */