P2P fixes for BRCM

1. Fix for stopping any on-going P2P-FIND, while doing a P2P-GROUP-ADD.
2. Fix for Supplicant crash. The crash was due to socket being closed
   during P2P-GROUP-REMOVE.
3. Append P2P DEV ADDR during AP-STA-CONNECTED Event for P2P Devices.
   For legacy STA, the event format would remain the same.
BUG: b/5262575

Change-Id: I8faf2159d35538fd07e42dba82d367b581cf2164
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 81ebe9b..72c90b1 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1244,6 +1244,16 @@
  */
 int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
 			  const u8 *ie, size_t len);
+#ifdef ANDROID_BRCM_P2P_PATCH
+/**
+ * p2p_group_get_dev_addr - Retreive the device address of an assocated P2P
+ * client. 
+ * @group: P2P group context from p2p_group_init()
+ * @addr: Interface address of the P2P client
+ * Returns: P2P dev_addr on success, NULL on failure
+ */
+u8 *p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr);
+#endif /*ANDROID_BRCM_P2P_PATCH */
 
 /**
  * p2p_group_assoc_resp_ie - Build P2P IE for (re)association response
diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c
index 169985f..9fb9f00 100644
--- a/src/p2p/p2p_group.c
+++ b/src/p2p/p2p_group.c
@@ -547,6 +547,19 @@
 	return NULL;
 }
 
+#ifdef ANDROID_BRCM_P2P_PATCH
+u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr)
+{
+	struct p2p_group_member *m;
+
+	m = p2p_group_get_client_iface(group, addr);
+
+	if (m)
+		return m->dev_addr;
+	else
+		return NULL;
+}
+#endif /* ANDROID_BRCM_P2P_PATCH */
 
 static struct wpabuf * p2p_build_go_disc_req(void)
 {