-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For publishing EasyConnect data relevant to third party applications (such as publishing frames containing CCE IEs for EasyMesh DPP) Signed-off-by: Tucker Polomik <[email protected]>
- Loading branch information
1 parent
fe17161
commit 32f4ae0
Showing
7 changed files
with
176 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include "wifi_base.h" | ||
#include "wifi_events.h" | ||
#include "wifi_hal.h" | ||
|
||
#include <stdio.h> | ||
#include <stdbool.h> | ||
#include <stdlib.h> | ||
#include "wifi_hal.h" | ||
#include "wifi_ctrl.h" | ||
#include "wifi_util.h" | ||
#include "wifi_analytics.h" | ||
|
||
/** | ||
* @brief Is this IE a Wi-Fi Alliance CCE IE? | ||
* | ||
* @param ie The information element in question | ||
* @param ie_len Length of the information element in bytes. | ||
* @return true if this IE is a WFA CCE IE, otherwise false | ||
*/ | ||
static bool is_cce_ie(const uint8_t *const ie, size_t ie_len) | ||
{ | ||
static const uint8_t OUI_WFA[3] = { 0x50, 0x6F, 0x9A }; | ||
static const uint8_t CCE_CONSTANT = 0x1E; | ||
if (ie_len < 4) | ||
return false; | ||
return memcmp(ie, OUI_WFA, sizeof(OUI_WFA)) == 0 && *(ie + 3) == CCE_CONSTANT; | ||
} | ||
|
||
static void handle_wifi_event_scan_results(wifi_app_t *app, void *data) | ||
{ | ||
int i; | ||
scan_results_t *scan_results = (scan_results_t *)data; | ||
if (!scan_results) { | ||
wifi_util_dbg_print(WIFI_EASYCONNECT, "%s:%d: NULL scan data!\n", __func__, __LINE__); | ||
return; | ||
} | ||
for (i = 0; i < scan_results->num; i++) { | ||
wifi_bss_info_t *bss_info = &scan_results->bss[i]; | ||
if (!bss_info || !bss_info->ie || bss_info->ie_len == 0) { | ||
wifi_util_dbg_print(WIFI_EASYCONNECT, "%s:%d: Invalid BSS info! #%d\n", __func__, | ||
__LINE__, i); | ||
continue; | ||
} | ||
uint8_t *ie_pos = bss_info->ie; | ||
size_t ie_len_remaining = bss_info->ie_len; | ||
while (ie_len_remaining > 2) { | ||
uint8_t id = ie_pos[0]; | ||
uint8_t ie_len = ie_pos[1]; | ||
if (ie_len + 2 > ie_len_remaining) | ||
break; | ||
// 0xdd == Vendor IE | ||
if (id == 0xdd && is_cce_ie(ie_pos + 2, ie_len)) { | ||
wifi_util_dbg_print(WIFI_EASYCONNECT, | ||
"%s:%d: BSS %s Beacon and/or Probe Response contains WFA CCE IE!\n", __func__, | ||
__LINE__, bss_info->ssid); | ||
// TODO: publish wifi_bss_info_t to appropriate bus path | ||
} | ||
// next IE | ||
ie_len_remaining -= (ie_len + 2); | ||
ie_pos += (ie_len + 2); | ||
} | ||
} | ||
} | ||
|
||
static void handle_hal_event(wifi_app_t *app, wifi_event_subtype_t event_subtype, void *data) | ||
{ | ||
switch (event_subtype) { | ||
case wifi_event_scan_results: | ||
handle_wifi_event_scan_results(app, data); | ||
break; | ||
default: | ||
wifi_util_dbg_print(WIFI_EASYCONNECT, "%s:%d: unhandled event sub_type=%d\n", __func__, | ||
__LINE__, event_subtype); | ||
break; | ||
} | ||
} | ||
|
||
int easyconnect_event(wifi_app_t *app, wifi_event_t *event) | ||
{ | ||
switch (event->event_type) { | ||
case wifi_event_type_hal_ind: | ||
handle_hal_event(app, event->sub_type, event->u.ec_data); | ||
break; | ||
default: | ||
wifi_util_dbg_print(WIFI_EASYCONNECT, "%s:%d: unhandled event_type=%d\n", __func__, | ||
__LINE__, event->event_type); | ||
break; | ||
} | ||
} | ||
|
||
int easyconnect_init(wifi_app_t *app, unsigned int create_flags) | ||
{ | ||
wifi_util_dbg_print(WIFI_EASYCONNECT, "%s called.", __func__); | ||
return 0; | ||
} | ||
|
||
int easyconnect_deinit(wifi_app_t *app) | ||
{ | ||
wifi_util_dbg_print(WIFI_EASYCONNECT, "%s called.", __func__); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/************************************************************************************ | ||
If not stated otherwise in this file or this component's LICENSE file the | ||
following copyright and licenses apply: | ||
Copyright 2024 RDK Management | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
**************************************************************************/ | ||
|
||
#ifndef _WIFI_EASYCONNECT_H | ||
#define _WIFI_EASYCONNECT_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
// EasyConnect relevant constructs | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif // __cplusplus | ||
|
||
#endif // _WIFI_EASYCONNECT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters