diff --git a/include/wifi/hdf_wifi_event.h b/include/wifi/hdf_wifi_event.h index 4aad40b7681bb68c0e0f7bc7c34d5dbf37c02411..3cccdb6ef666658a83a21188bd9ac9c3623a99ec 100644 --- a/include/wifi/hdf_wifi_event.h +++ b/include/wifi/hdf_wifi_event.h @@ -476,6 +476,10 @@ int32_t HdfWifiEventEapolRecv(const char *name, void *context); */ int32_t HdfWifiEventResetResult(const uint8_t chipId, int32_t resetStatus, const char *ifName); +int32_t HdfWifiEventRemainOnChannel(const struct NetDevice *netDev, uint32_t freq, uint32_t duration); + +int32_t HdfWifiEventCancelRemainOnChannel(const struct NetDevice *netDev, uint32_t freq); + #ifdef __cplusplus #if __cplusplus } diff --git a/include/wifi/wifi_mac80211_ops.h b/include/wifi/wifi_mac80211_ops.h index 4e1244bfb85bbfd160ac30945607ffdc22486bce..7869d6c4830ff15de0b91698657e5dacfa298966 100644 --- a/include/wifi/wifi_mac80211_ops.h +++ b/include/wifi/wifi_mac80211_ops.h @@ -168,7 +168,14 @@ enum Ieee80211ChannelWidth { */ enum WlanWorkMode { WLAN_WORKMODE_STA = 2, /**< STA mode */ - WLAN_WORKMODE_AP = 3 /**< AP mode */ + WLAN_WORKMODE_AP = 3, /**< AP mode */ + WLAN_WORKMODE_AP_VLAN, + WLAN_WORKMODE_WDS, + WLAN_WORKMODE_MONITOR, + WLAN_WORKMODE_MESH_POINT, + WLAN_WORKMODE_P2P_CLIENT, + WLAN_WORKMODE_P2P_GO, + WLAN_WORKMODE_P2P_DEVICE, }; /** @@ -302,7 +309,7 @@ struct WlanScanRequest { uint8_t freqsCount; /**< Number of frequencies */ uint8_t *bssid; /**< BSSID to scan for */ struct WlanSSID *ssids; /**< SSIDs to scan for */ - uint16_t *freqs; /**< An array of frequencies */ + uint32_t *freqs; /**< An array of frequencies */ uint32_t extraIEsLen; /**< Length of an extended information element (IE) */ uint8_t *extraIEs; /**< Extended IEs */ }; @@ -581,6 +588,23 @@ struct HdfMac80211BaseOps { * @version 1.0 */ int32_t (*GetHwCapability)(NetDevice *netDev, struct WlanHwCapability **capability); + + int32_t (*RemainOnChannel)(NetDevice *netDev, WifiOnChannel *onChannel); + + int32_t (*CancelRemainOnChannel)(NetDevice *netDev); + + int32_t (*ProbeReqReport)(NetDevice *netDev, int32_t report); + + int32_t (*AddIf)(NetDevice *netDev, WifiIfAdd *ifAdd); + + int32_t (*RemoveIf)(NetDevice *netDev, WifiIfRemove *ifRemove); + + int32_t (*SetApWpsP2pIe)(NetDevice *netDev, WifiAppIe *appIe); + + int32_t (*GetDriverFlag)(struct NetDevice *netDev, WifiGetDrvFlags **params); + + int32_t (*SendAction)(struct NetDevice *netDev, WifiActionData *actionData); + }; /** diff --git a/model/network/wifi/core/module/wifi_base.c b/model/network/wifi/core/module/wifi_base.c index 1857174d78e37adad2b741e48b5bf1f09474c256..d0c3d19b0dfbcfe02c58eb285a9424d594c22180 100644 --- a/model/network/wifi/core/module/wifi_base.c +++ b/model/network/wifi/core/module/wifi_base.c @@ -719,13 +719,70 @@ static int32_t WifiSendMlme(const RequestContext *context, struct HdfSBuf *reqDa return HDF_SUCCESS; } +int32_t SendAction(struct NetDevice *netdev, WifiActionData *actionData) +{ + struct HdfChipDriver *chipDriver = GetChipDriver(netdev); + if (chipDriver == NULL) { + HDF_LOGE("%s:bad net device found!", __func__); + return HDF_FAILURE; + } + + RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->ops, SendAction); + return chipDriver->ops->SendAction(netdev, actionData); +} + static int32_t WifiCmdSendAction(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData) { + WifiActionData actionData = {0}; + const char *ifName = NULL; + uint32_t dataSize = 0; + struct NetDevice *netdev = NULL; + (void)context; - (void)reqData; (void)rspData; + if (reqData == NULL) { + HDF_LOGE("%s:reqData is NULL", __func__); + return HDF_ERR_INVALID_PARAM; + } + ifName = HdfSbufReadString(reqData); + if (ifName == NULL) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName"); + return HDF_FAILURE; + } - return HDF_SUCCESS; + if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.bssid), &dataSize) || + dataSize != ETH_ADDR_LEN) { + HDF_LOGE("%s: %s!ParamName=%s,readSize=%u", __func__, ERROR_DESC_READ_REQ_FAILED, "bssid", dataSize); + return HDF_FAILURE; + } + + if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.dst), &dataSize) || + dataSize != ETH_ADDR_LEN) { + HDF_LOGE("%s: %s!ParamName=%s,readSize=%u", __func__, ERROR_DESC_READ_REQ_FAILED, "dst", dataSize); + return HDF_FAILURE; + } + + if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.src), &dataSize) || + dataSize != ETH_ADDR_LEN) { + HDF_LOGE("%s: %s!ParamName=%s,readSize=%u", __func__, ERROR_DESC_READ_REQ_FAILED, "src", dataSize); + return HDF_FAILURE; + } + + if (!HdfSbufReadBuffer(reqData, (const void **)&(actionData.data), &(actionData.dataLen))) { + HDF_LOGE("%s: %s!ParamName=%s,readSize=%u", __func__, ERROR_DESC_READ_REQ_FAILED, "data", actionData.dataLen); + return HDF_FAILURE; + } + netdev = NetDeviceGetInstByName(ifName); + if (netdev == NULL || netdev->netDeviceIf == NULL) { + HDF_LOGE("%s:netdev not found!ifName=%s", __func__, ifName); + return HDF_FAILURE; + } + + int ret = SendAction(netdev, &actionData); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: fail to remain on channel,%d", __func__, ret); + } + return ret; } static int32_t WifiCmdGetNetworkInfo(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData) @@ -1214,6 +1271,333 @@ static int32_t WifiCmdResetDriver(const RequestContext *context, struct HdfSBuf return ret; } +static int32_t RemainOnChannel(struct NetDevice *netdev, WifiOnChannel *onChannel) +{ + struct HdfChipDriver *chipDriver = GetChipDriver(netdev); + if (chipDriver == NULL) { + HDF_LOGE("%s:bad net device found!", __func__); + return HDF_FAILURE; + } + + RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->ops, RemainOnChannel); + return chipDriver->ops->RemainOnChannel(netdev, onChannel); +} + +static int32_t WifiCmdRemainOnChannel(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData) +{ + int32_t ret; + struct NetDevice *netdev = NULL; + const char *ifName = NULL; + WifiOnChannel wifiOnChannel = {0}; + + (void)context; + if (reqData == NULL || rspData == NULL) { + return HDF_ERR_INVALID_PARAM; + } + ifName = HdfSbufReadString(reqData); + if (ifName == NULL) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName"); + return HDF_FAILURE; + } + netdev = NetDeviceGetInstByName(ifName); + if (netdev == NULL) { + HDF_LOGE("%s: netdev not found!ifName=%s", __func__, ifName); + return HDF_FAILURE; + } + if (!HdfSbufReadUint32(reqData, &(wifiOnChannel.freq))) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "freq"); + return HDF_FAILURE; + } + if (!HdfSbufReadUint32(reqData, &(wifiOnChannel.duration))) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "duration"); + return HDF_FAILURE; + } + ret = RemainOnChannel(netdev, &wifiOnChannel); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: fail to remain on channel,%d",__func__, ret); + } + return ret; +} + +static int32_t ProbeReqReport(struct NetDevice *netdev, int32_t report) +{ + struct HdfChipDriver *chipDriver = GetChipDriver(netdev); + if (chipDriver == NULL) { + HDF_LOGE("%s:bad net device found!", __func__); + return HDF_FAILURE; + } + + RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->ops, ProbeReqReport); + return chipDriver->ops->ProbeReqReport(netdev, report); +} + +static int32_t WifiCmdProbeReqReport(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData) +{ + int32_t ret; + struct NetDevice *netdev = NULL; + const char *ifName = NULL; + int32_t report; + + (void)context; + if (reqData == NULL || rspData == NULL) { + return HDF_ERR_INVALID_PARAM; + } + ifName = HdfSbufReadString(reqData); + if (ifName == NULL) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName"); + return HDF_FAILURE; + } + netdev = NetDeviceGetInstByName(ifName); + if (netdev == NULL) { + HDF_LOGE("%s: netdev not found!ifName=%s", __func__, ifName); + return HDF_FAILURE; + } + if (!HdfSbufReadInt32(reqData,&(report))) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "report"); + return HDF_FAILURE; + } + + ret = ProbeReqReport(netdev, report); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: fail to probe req report,%d",__func__, ret); + } + return ret; +} + +static int32_t CancelRemainOnChannel(struct NetDevice *netdev) +{ + struct HdfChipDriver *chipDriver = GetChipDriver(netdev); + if (chipDriver == NULL) { + HDF_LOGE("%s:bad net device found!", __func__); + return HDF_FAILURE; + } + + RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->ops, CancelRemainOnChannel); + return chipDriver->ops->CancelRemainOnChannel(netdev); +} + +static int32_t WifiCmdCancelRemainOnChannel(const RequestContext *context, struct HdfSBuf *reqData, + struct HdfSBuf *rspData) +{ + int32_t ret; + struct NetDevice *netdev = NULL; + const char *ifName = NULL; + + (void)context; + if (reqData == NULL || rspData == NULL) { + return HDF_ERR_INVALID_PARAM; + } + ifName = HdfSbufReadString(reqData); + if (ifName == NULL) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName"); + return HDF_FAILURE; + } + netdev = NetDeviceGetInstByName(ifName); + if (netdev == NULL) { + HDF_LOGE("%s: netdev not found!ifName=%s", __func__, ifName); + return HDF_FAILURE; + } + + ret = CancelRemainOnChannel(netdev); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: fail to cancel remain on channel,%d",__func__, ret); + } + return ret; +} + +static int32_t AddIf(struct NetDevice *netdev, WifiIfAdd *ifAdd) +{ + struct HdfChipDriver *chipDriver = GetChipDriver(netdev); + if (chipDriver == NULL) { + HDF_LOGE("%s:bad net device found!", __func__); + return HDF_FAILURE; + } + + RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->ops, AddIf); + return chipDriver->ops->AddIf(netdev, ifAdd); +} + +static int32_t WifiCmdAddIf(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData) +{ + int32_t ret; + struct NetDevice *netdev = NULL; + const char *ifName = NULL; + WifiIfAdd ifAdd = {0}; + + (void)context; + if (reqData == NULL || rspData == NULL) { + return HDF_ERR_INVALID_PARAM; + } + ifName = HdfSbufReadString(reqData); + if (ifName == NULL) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName"); + return HDF_FAILURE; + } + netdev = NetDeviceGetInstByName(ifName); + if (netdev == NULL) { + HDF_LOGE("%s: netdev not found!ifName=%s", __func__, ifName); + return HDF_FAILURE; + } + + if (!HdfSbufReadUint8(reqData, &(ifAdd.type))) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "type"); + return HDF_FAILURE; + } + + ret = AddIf(netdev, &ifAdd); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: fail to cancel remain on channel,%d",__func__, ret); + } + return ret; +} + +static int32_t RemoveIf(struct NetDevice *netdev, WifiIfRemove *ifRemove) +{ + struct HdfChipDriver *chipDriver = GetChipDriver(netdev); + if (chipDriver == NULL) { + HDF_LOGE("%s:bad net device found!", __func__); + return HDF_FAILURE; + } + + RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->ops, RemoveIf); + return chipDriver->ops->RemoveIf(netdev, ifRemove); +} + +static int32_t WifiCmdRemoveIf(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData) +{ + int32_t ret; + struct NetDevice *netdev = NULL; + const char *ifName = NULL; + WifiIfRemove *ifRemove = NULL; + + (void)context; + if (reqData == NULL || rspData == NULL) { + return HDF_ERR_INVALID_PARAM; + } + ifName = HdfSbufReadString(reqData); + if (ifName == NULL) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName"); + return HDF_FAILURE; + } + netdev = NetDeviceGetInstByName(ifName); + if (netdev == NULL) { + HDF_LOGE("%s: netdev not found!ifName=%s", __func__, ifName); + return HDF_FAILURE; + } + + uint32_t dataSize = 0; + if (!HdfSbufReadBuffer(reqData, (const void **)&(ifRemove), &dataSize) || dataSize != sizeof(WifiIfRemove)) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName"); + return HDF_FAILURE; + } + ret = RemoveIf(netdev, ifRemove); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: fail to remove interface,%d",__func__, ret); + } + return ret; +} + +static int32_t SetApWpsP2pIe(struct NetDevice *netdev, WifiAppIe *appIe) +{ + struct HdfChipDriver *chipDriver = GetChipDriver(netdev); + if (chipDriver == NULL) { + HDF_LOGE("%s:bad net device found!", __func__); + return HDF_FAILURE; + } + + RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->ops, SetApWpsP2pIe); + return chipDriver->ops->SetApWpsP2pIe(netdev, appIe); +} + +static int32_t WifiCmdSetApWpsP2pIe(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData) +{ + int32_t ret; + struct NetDevice *netdev = NULL; + const char *ifName = NULL; + WifiAppIe appIe = {0}; + + (void)context; + if (reqData == NULL || rspData == NULL) { + return HDF_ERR_INVALID_PARAM; + } + ifName = HdfSbufReadString(reqData); + if (ifName == NULL) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName"); + return HDF_FAILURE; + } + netdev = NetDeviceGetInstByName(ifName); + if (netdev == NULL) { + HDF_LOGE("%s: netdev not found!ifName=%s", __func__, ifName); + return HDF_FAILURE; + } + + if (!HdfSbufReadUint32(reqData, &(appIe.ieLen))) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ieLen"); + return HDF_FAILURE; + } + if (!HdfSbufReadUint8(reqData, &(appIe.appIeType))) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "appIeType"); + return HDF_FAILURE; + } + if (!HdfSbufReadBuffer(reqData, (const void**)&(appIe.ie), &(appIe.ieLen))) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "appIeType"); + return HDF_FAILURE; + } + ret = SetApWpsP2pIe(netdev, &appIe); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: fail to setapwpsp2pie,%d",__func__, ret); + } + return ret; +} + +int32_t GetDriverFlag (struct NetDevice *netdev, WifiGetDrvFlags **params) +{ + struct HdfChipDriver *chipDriver = GetChipDriver(netdev); + if (chipDriver == NULL) { + HDF_LOGE("%s:bad net device found!", __func__); + return HDF_FAILURE; + } + + RETURN_IF_CHIPOPS_NOT_IMPLEMENT(chipDriver->ops, GetDriverFlag); + return chipDriver->ops->GetDriverFlag(netdev, params); +} + +static int32_t WifiCmdGetDriverFlag(const RequestContext *context, struct HdfSBuf *reqData, struct HdfSBuf *rspData) +{ + int32_t ret; + struct NetDevice *netdev = NULL; + const char *ifName = NULL; + WifiGetDrvFlags *params = NULL; + + (void)context; + if (reqData == NULL || rspData == NULL) { + return HDF_ERR_INVALID_PARAM; + } + ifName = HdfSbufReadString(reqData); + if (ifName == NULL) { + HDF_LOGE("%s: %s!ParamName=%s", __func__, ERROR_DESC_READ_REQ_FAILED, "ifName"); + return HDF_FAILURE; + } + netdev = NetDeviceGetInstByName(ifName); + if (netdev == NULL) { + HDF_LOGE("%s: netdev not found!ifName=%s", __func__, ifName); + return HDF_FAILURE; + } + + ret = GetDriverFlag(netdev, ¶ms); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: fail to getdriverflag,%d",__func__, ret); + } + + if (!HdfSbufWriteUint64(rspData, params->drvFlags)) { + HDF_LOGE("%s:%s!", __func__, ERROR_DESC_WRITE_RSP_FAILED); + ret = HDF_ERR_IO; + } + + HDF_LOGE("WifiCmdGetDriverFlag:%llx", params->drvFlags); + return ret; +} + static struct MessageDef g_wifiBaseFeatureCmds[] = { DUEMessage(CMD_BASE_NEW_KEY, WifiCmdNewKey, 0), DUEMessage(CMD_BASE_DEL_KEY, WifiCmdDelKey, 0), @@ -1240,6 +1624,13 @@ static struct MessageDef g_wifiBaseFeatureCmds[] = { DUEMessage(CMD_BASE_GET_IFNAMES, WifiCmdGetIfNamesByChipId, 0), DUEMessage(CMD_BASE_RESET_DRIVER, WifiCmdResetDriver, 0), DUEMessage(CMD_BASE_DO_RESET_PRIVATE, WifiCmdDoResetChip, 0), + DUEMessage(CMD_P2P_PROBE_REQ_REPORT, WifiCmdProbeReqReport, 0), + DUEMessage(CMD_P2P_REMAIN_ON_CHANNEL, WifiCmdRemainOnChannel, 0), + DUEMessage(CMD_P2P_CANCEL_REMAIN_ON_CHANNEL, WifiCmdCancelRemainOnChannel, 0), + DUEMessage(CMD_P2P_ADD_IF, WifiCmdAddIf, 0), + DUEMessage(CMD_P2P_REMOVE_IF, WifiCmdRemoveIf, 0), + DUEMessage(CMD_P2P_SET_AP_WPS_P2P_IE, WifiCmdSetApWpsP2pIe, 0), + DUEMessage(CMD_P2P_GET_DRIVER_FLAGS, WifiCmdGetDriverFlag, 0), }; ServiceDefine(BaseService, BASE_SERVICE_ID, g_wifiBaseFeatureCmds); diff --git a/model/network/wifi/include/hdf_wifi_cmd.h b/model/network/wifi/include/hdf_wifi_cmd.h index 9f0f17c000d28f3904341c667ea2ba3517e3bfec..43a392eadb3f148df3642766ea7117db6e779cd0 100644 --- a/model/network/wifi/include/hdf_wifi_cmd.h +++ b/model/network/wifi/include/hdf_wifi_cmd.h @@ -205,6 +205,30 @@ typedef struct { size_t dataLen; } WifiActionData; +typedef struct { + uint32_t freq; + uint32_t duration; +} WifiOnChannel; + +typedef struct { + uint8_t type; +} WifiIfAdd; + +typedef struct { + uint8_t ifname[IFNAMSIZ]; +} WifiIfRemove; + +typedef struct { + uint32_t ieLen; + uint8_t appIeType; + uint8_t rsv[3]; + uint8_t *ie; +} WifiAppIe; + +typedef struct { + uint64_t drvFlags; +} WifiGetDrvFlags; + typedef struct { int32_t mode; int32_t freq; @@ -314,16 +338,6 @@ typedef struct { int32_t extraIesLen; } WifiScan; -typedef struct { - uint32_t freq; - uint32_t duration; -} WifiOnChannel; - - -typedef struct { - uint8_t ifname[IFNAMSIZ]; -} WifiIfRemove; - typedef struct { uint8_t type; uint8_t macAddr[ETH_ADDR_LEN]; @@ -335,10 +349,6 @@ typedef struct { uint8_t *macAddr; } WifiIftypeMacAddr; -typedef struct { - uint64_t drvFlags; -} WifiGetDrvFlags; - typedef struct { int32_t freq; } WifiChannelSwitch; diff --git a/model/network/wifi/platform/include/hdf_wlan_services.h b/model/network/wifi/platform/include/hdf_wlan_services.h index cbc7e5fbc33ac049c87e53bd9a4353f229cfe2fc..ad4e1148d63dd839471ea1788a3e683a619f9fe7 100644 --- a/model/network/wifi/platform/include/hdf_wlan_services.h +++ b/model/network/wifi/platform/include/hdf_wlan_services.h @@ -43,6 +43,13 @@ enum BaseCommands { CMD_BASE_GET_IFNAMES, CMD_BASE_RESET_DRIVER, CMD_BASE_DO_RESET_PRIVATE = 25, + CMD_P2P_PROBE_REQ_REPORT = 26, + CMD_P2P_REMAIN_ON_CHANNEL, + CMD_P2P_CANCEL_REMAIN_ON_CHANNEL, + CMD_P2P_ADD_IF, + CMD_P2P_REMOVE_IF, + CMD_P2P_SET_AP_WPS_P2P_IE, + CMD_P2P_GET_DRIVER_FLAGS, }; enum APCommands { diff --git a/model/network/wifi/platform/src/hdf_wifi_event.c b/model/network/wifi/platform/src/hdf_wifi_event.c index 109577831121d85a2ec02e194a584ebdc97ff2b2..e519a13fc0023e1a4a474fea692921578510d3a1 100644 --- a/model/network/wifi/platform/src/hdf_wifi_event.c +++ b/model/network/wifi/platform/src/hdf_wifi_event.c @@ -430,6 +430,51 @@ int32_t HdfWifiEventResetResult(const uint8_t chipId, int32_t resetStatus, const return ret; } +int32_t HdfWifiEventRemainOnChannel(const struct NetDevice *netDev, uint32_t freq, uint32_t duration) +{ + struct HdfSBuf *data = NULL; + int32_t ret; + + data = HdfSBufObtainDefaultSize(); + if (data == NULL) { + HDF_LOGE("%s InitDataBlock failed", __func__); + return HDF_FAILURE; + } + if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteUint32(data, freq)) { + HDF_LOGE("%s sbuf write failed", __func__); + HdfSBufRecycle(data); + return HDF_FAILURE; + } + if (!HdfSbufWriteUint32(data, duration)) { + HDF_LOGE("%s sbuf write failed", __func__); + HdfSBufRecycle(data); + return HDF_FAILURE; + } + ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_REMAIN_ON_CHANNEL, data); + HdfSBufRecycle(data); + return ret; +} + +int32_t HdfWifiEventCancelRemainOnChannel(const struct NetDevice *netDev, uint32_t freq) +{ + struct HdfSBuf *data = NULL; + int32_t ret; + + data = HdfSBufObtainDefaultSize(); + if (data == NULL) { + HDF_LOGE("%s InitDataBlock failed", __func__); + return HDF_FAILURE; + } + if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteUint32(data, freq)) { + HDF_LOGE("%s sbuf write failed", __func__); + HdfSBufRecycle(data); + return HDF_FAILURE; + } + ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_CANCEL_REMAIN_ON_CHANNEL, data); + HdfSBufRecycle(data); + return ret; +} + #ifdef __cplusplus #if __cplusplus }