Skip to content

Commit

Permalink
Add EasyConnect app
Browse files Browse the repository at this point in the history
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
tuckerpo-cl committed Jan 6, 2025
1 parent fe17161 commit 32f4ae0
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 4 deletions.
3 changes: 3 additions & 0 deletions build/linux/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ ifdef ONEWIFI_BLASTER_APP_SUPPORT
WEBCONFIG_SOURCES += $(ONE_WIFI_HOME)/source/webconfig/wifi_webconfig_blaster.c
endif

ifdef ONEWIFI_EASYCONNECT_APP_SUPPORT
CSOURCES += $(wildcard $(ONE_WIFI_HOME)/source/apps/easyconnect/*.c)
endif

COBJECTS = $(CSOURCES:.c=.o) # expands to list of object files

Expand Down
4 changes: 3 additions & 1 deletion include/wifi_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ typedef enum {
wifi_app_inst_whix = wifi_app_inst_base << 13,
wifi_app_inst_core = wifi_app_inst_base << 14,
wifi_app_inst_ocs = wifi_app_inst_base << 15,
wifi_app_inst_max = wifi_app_inst_base << 16
wifi_app_inst_easyconnect = wifi_app_inst_base << 16,
wifi_app_inst_max = wifi_app_inst_base << 17
} wifi_app_inst_t;

typedef struct {
Expand All @@ -133,6 +134,7 @@ typedef struct {
} wifi_core_data_t;

typedef void *wifi_analytics_data_t;
typedef void *wifi_easyconnect_data_t;

#define MAC_ADDR_LEN 6
#define STA_KEY_LEN 2*MAC_ADDR_LEN + 6
Expand Down
1 change: 1 addition & 0 deletions include/wifi_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ typedef struct {
wifi_provider_response_t *provider_response;
webconfig_subdoc_data_t *webconfig_data;
wifi_csi_dev_t *csi;
wifi_easyconnect_data_t *ec_data;
} u;
} wifi_event_t;

Expand Down
101 changes: 101 additions & 0 deletions source/apps/easyconnect/wifi_easyconnect.c
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;
}
33 changes: 33 additions & 0 deletions source/apps/easyconnect/wifi_easyconnect.h
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
35 changes: 33 additions & 2 deletions source/apps/wifi_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,28 @@ int blaster_event(wifi_app_t *app, wifi_event_t *event)
return 0;
}

#endif
#endif // ONEWIFI_BLASTER_APP_SUPPORT

#ifdef ONEWIFI_EASYCONNECT_APP_SUPPORT
extern int easyconnect_init(wifi_app_t *app, unsigned int create_flag);
extern int easyconnect_deinit(wifi_app_t *app);
extern int easyconnect_event(wifi_app_t *app, wifi_event_t *event);
#else
int easyconnect_init(wifi_app_t *app, unsigned int create_flag)
{
return 0;
}

int easyconnect_deinit(wifi_app_t *app)
{
return 0;
}

int easyconnect_event(wifi_app_t *app, wifi_event_t *event)
{
return 0;
}
#endif // ONEWIFI_EASYCONNECT_APP_SUPPORT


wifi_app_descriptor_t app_desc[] = {
Expand Down Expand Up @@ -280,7 +301,17 @@ wifi_app_descriptor_t app_desc[] = {
"Blaster",
blaster_init, blaster_event, blaster_deinit,
NULL, NULL
}
},
#ifdef ONEWIFI_EASYCONNECT_APP_SUPPORT
{
wifi_app_inst_easyconnect, 0,
wifi_event_type_hal_ind,
true, true,
"EasyConnect",
easyconnect_init, easyconnect_event, easyconnect_deinit,
NULL, NULL
},
#endif // ONEWIFI_EASYCONNECT_APP_SUPPORT

};

Expand Down
3 changes: 2 additions & 1 deletion source/utils/wifi_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ typedef enum {
WIFI_BLASTER,
WIFI_OCS,
WIFI_BUS,
WIFI_TCM
WIFI_TCM,
WIFI_EASYCONNECT
} wifi_dbg_type_t;

typedef enum {
Expand Down

0 comments on commit 32f4ae0

Please sign in to comment.