p2p: support using pre-defined passphrase for adding a new P2P group
wpas_p2p_group_add could use pre-defined network, but always generate
passphrase randomly. Provide a way to use pre-defined passphrase.
Bug: 64695709
Test: Group creation
* create a group with a configuration.
* join it as new Group Client.
* join it as new Group Client.
Change-Id: I08fbfd6542a5c1e76335c3a5911ba09ea6d9ca78
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index b4660c4..585b4a0 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1797,7 +1797,12 @@
}
p2p->ssid_set = 0;
- p2p_random(params->passphrase, p2p->cfg->passphrase_len);
+ if (p2p->passphrase_set) {
+ os_memcpy(params->passphrase, p2p->passphrase, os_strlen(p2p->passphrase));
+ } else {
+ p2p_random(params->passphrase, p2p->cfg->passphrase_len);
+ }
+ p2p->passphrase_set = 0;
return 0;
}
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index 6a4d751..a73d99e 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -11,6 +11,7 @@
#include "utils/list.h"
#include "p2p.h"
+#include "ap/ap_config.h"
#define P2P_GO_NEG_CNF_MAX_RETRY_COUNT 1
@@ -358,6 +359,16 @@
int ssid_set;
/**
+ * passphrase - WPA2-Personal passphrase for GO Negotiation (if local end will be GO)
+ */
+ char passphrase[MAX_PASSPHRASE_LEN + 1];
+
+ /**
+ * passphrase_set - Whether passphrase is already set for GO Negotiation
+ */
+ int passphrase_set;
+
+ /**
* Regulatory class for own operational channel
*/
u8 op_reg_class;