IP Address Allocation in EAPOL-Key Frames

Implementation of Wi-Fi P2P Technical Specification v1.7 - Section  4.2.8
"IP Address Allocation in EAPOL-Key Frames (4-Way Handshake)".

Changes includes,
1. Configure the IP addresses in supplicant for P2P GO to provide the IP address to
client in EAPOL handshake.
2. Send the received IP address information to framework.

Bug: 170056953
Test: Manual - Establish P2P connection & confirmed from sniffer logs
      and logcat logs that IP addresse is allocated via EAPOL exchange.
      Ping works after connection.
Change-Id: I5978708b098e57e48db52dae14f9bbba28199f2d
This commit is contained in:
Sunil Ravi
2023-02-04 06:17:03 +00:00
parent 07411a81c8
commit 68c25c259b
7 changed files with 50 additions and 7 deletions

View File

@@ -517,7 +517,7 @@ void wpas_aidl_notify_p2p_group_formation_failure(
void wpas_aidl_notify_p2p_group_started( void wpas_aidl_notify_p2p_group_started(
struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int persistent, struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int persistent,
int client) int client, const u8 *ip)
{ {
if (!wpa_s || !ssid) if (!wpa_s || !ssid)
return; return;
@@ -530,7 +530,7 @@ void wpas_aidl_notify_p2p_group_started(
if (!aidl_manager) if (!aidl_manager)
return; return;
aidl_manager->notifyP2pGroupStarted(wpa_s, ssid, persistent, client); aidl_manager->notifyP2pGroupStarted(wpa_s, ssid, persistent, client, ip);
} }
void wpas_aidl_notify_p2p_group_removed( void wpas_aidl_notify_p2p_group_removed(

View File

@@ -79,7 +79,7 @@ extern "C"
struct wpa_supplicant *wpa_s, const char *reason); struct wpa_supplicant *wpa_s, const char *reason);
void wpas_aidl_notify_p2p_group_started( void wpas_aidl_notify_p2p_group_started(
struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid,
int persistent, int client); int persistent, int client, const u8 *ip);
void wpas_aidl_notify_p2p_group_removed( void wpas_aidl_notify_p2p_group_removed(
struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid,
const char *role); const char *role);
@@ -228,7 +228,7 @@ static void wpas_aidl_notify_p2p_group_formation_failure(
{} {}
static void wpas_aidl_notify_p2p_group_started( static void wpas_aidl_notify_p2p_group_started(
struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int persistent, struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int persistent,
int client) int client, const u8 *ip)
{} {}
static void wpas_aidl_notify_p2p_group_removed( static void wpas_aidl_notify_p2p_group_removed(
struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, const char *role) struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, const char *role)

View File

@@ -1353,7 +1353,7 @@ void AidlManager::notifyP2pGroupFormationFailure(
void AidlManager::notifyP2pGroupStarted( void AidlManager::notifyP2pGroupStarted(
struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid, struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid,
int persistent, int client) int persistent, int client, const u8 *ip)
{ {
if (!wpa_group_s || !wpa_group_s->parent || !ssid) if (!wpa_group_s || !wpa_group_s->parent || !ssid)
return; return;
@@ -1394,7 +1394,17 @@ void AidlManager::notifyP2pGroupStarted(
params.goDeviceAddress = macAddrToVec(wpa_group_s->go_dev_addr); params.goDeviceAddress = macAddrToVec(wpa_group_s->go_dev_addr);
params.goInterfaceAddress = aidl_is_go ? macAddrToVec(wpa_group_s->own_addr) : params.goInterfaceAddress = aidl_is_go ? macAddrToVec(wpa_group_s->own_addr) :
macAddrToVec(wpa_group_s->current_bss->bssid); macAddrToVec(wpa_group_s->current_bss->bssid);
if (NULL != ip && !aidl_is_go) {
params.isP2pClientEapolIpAddressInfoPresent = true;
os_memcpy(&params.p2pClientIpInfo.ipAddressClient, &ip[0], 4);
os_memcpy(&params.p2pClientIpInfo.ipAddressMask, &ip[4], 4);
os_memcpy(&params.p2pClientIpInfo.ipAddressGo, &ip[8], 4);
wpa_printf(MSG_DEBUG, "P2P: IP Address allocated - CLI: 0x%x MASK: 0x%x GO: 0x%x",
params.p2pClientIpInfo.ipAddressClient,
params.p2pClientIpInfo.ipAddressMask,
params.p2pClientIpInfo.ipAddressGo);
}
callWithEachP2pIfaceCallback( callWithEachP2pIfaceCallback(
misc_utils::charBufToString(wpa_s->ifname), misc_utils::charBufToString(wpa_s->ifname),
std::bind(&ISupplicantP2pIfaceCallback::onGroupStartedWithParams, std::bind(&ISupplicantP2pIfaceCallback::onGroupStartedWithParams,

View File

@@ -104,7 +104,7 @@ public:
struct wpa_supplicant *wpa_s, const char *reason); struct wpa_supplicant *wpa_s, const char *reason);
void notifyP2pGroupStarted( void notifyP2pGroupStarted(
struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid, struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid,
int persistent, int client); int persistent, int client, const u8 *ip);
void notifyP2pGroupRemoved( void notifyP2pGroupRemoved(
struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid, struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid,
const char *role); const char *role);

View File

@@ -809,6 +809,16 @@ ndk::ScopedAStatus P2pIface::addGroup(
&P2pIface::setVendorElementsInternal, in_frameTypeMask, in_vendorElemBytes); &P2pIface::setVendorElementsInternal, in_frameTypeMask, in_vendorElemBytes);
} }
::ndk::ScopedAStatus P2pIface::configureEapolIpAddressAllocationParams(
int32_t in_ipAddressGo, int32_t in_ipAddressMask,
int32_t in_ipAddressStart, int32_t in_ipAddressEnd)
{
return validateAndCall(
this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
&P2pIface::configureEapolIpAddressAllocationParamsInternal,
in_ipAddressGo, in_ipAddressMask, in_ipAddressStart, in_ipAddressEnd);
}
std::pair<std::string, ndk::ScopedAStatus> P2pIface::getNameInternal() std::pair<std::string, ndk::ScopedAStatus> P2pIface::getNameInternal()
{ {
return {ifname_, ndk::ScopedAStatus::ok()}; return {ifname_, ndk::ScopedAStatus::ok()};
@@ -1824,6 +1834,23 @@ ndk::ScopedAStatus P2pIface::setVendorElementsInternal(
return ndk::ScopedAStatus::ok(); return ndk::ScopedAStatus::ok();
} }
ndk::ScopedAStatus P2pIface::configureEapolIpAddressAllocationParamsInternal(
uint32_t ipAddressGo, uint32_t ipAddressMask,
uint32_t ipAddressStart, uint32_t ipAddressEnd)
{
wpa_printf(MSG_DEBUG, "P2P: Configure IP addresses for IP allocation in EAPOL"
" ipAddressGo: 0x%x mask: 0x%x Range - Start: 0x%x End: 0x%x",
ipAddressGo, ipAddressMask, ipAddressStart, ipAddressEnd);
struct wpa_supplicant* wpa_s = retrieveIfacePtr();
os_memcpy(wpa_s->conf->ip_addr_go, &ipAddressGo, 4);
os_memcpy(wpa_s->conf->ip_addr_mask, &ipAddressMask, 4);
os_memcpy(wpa_s->conf->ip_addr_start, &ipAddressStart, 4);
os_memcpy(wpa_s->conf->ip_addr_end, &ipAddressEnd, 4);
return ndk::ScopedAStatus::ok();
}
/** /**
* Retrieve the underlying |wpa_supplicant| struct * Retrieve the underlying |wpa_supplicant| struct
* pointer for this iface. * pointer for this iface.

View File

@@ -172,6 +172,9 @@ public:
::ndk::ScopedAStatus setVendorElements( ::ndk::ScopedAStatus setVendorElements(
P2pFrameTypeMask in_frameTypeMask, P2pFrameTypeMask in_frameTypeMask,
const std::vector<uint8_t>& in_vendorElemBytes) override; const std::vector<uint8_t>& in_vendorElemBytes) override;
::ndk::ScopedAStatus configureEapolIpAddressAllocationParams(
int32_t in_ipAddressGo, int32_t in_ipAddressMask,
int32_t in_ipAddressStart, int32_t in_ipAddressEnd) override;
private: private:
// Corresponding worker functions for the AIDL methods. // Corresponding worker functions for the AIDL methods.
@@ -292,6 +295,9 @@ private:
ndk::ScopedAStatus setVendorElementsInternal( ndk::ScopedAStatus setVendorElementsInternal(
P2pFrameTypeMask frameTypeMask, P2pFrameTypeMask frameTypeMask,
const std::vector<uint8_t>& vendorElemBytes); const std::vector<uint8_t>& vendorElemBytes);
::ndk::ScopedAStatus configureEapolIpAddressAllocationParamsInternal(
uint32_t ipAddressGo, uint32_t ipAddressMask,
uint32_t ipAddressStart, uint32_t ipAddressEnd);
struct wpa_supplicant* retrieveIfacePtr(); struct wpa_supplicant* retrieveIfacePtr();
struct wpa_supplicant* retrieveGroupIfacePtr( struct wpa_supplicant* retrieveGroupIfacePtr(

View File

@@ -797,7 +797,7 @@ void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip); wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
wpas_aidl_notify_p2p_group_started(wpa_s, ssid, persistent, client); wpas_aidl_notify_p2p_group_started(wpa_s, ssid, persistent, client, ip);
} }