diff options
| author | chenyong <[email protected]> | 2020-02-29 17:12:48 +0800 |
|---|---|---|
| committer | chenyong <[email protected]> | 2020-02-29 17:12:48 +0800 |
| commit | 986b64cbe0946c81811b3ea7d3878b3b9399e8e0 (patch) | |
| tree | cc8fc24edb49d0ccd14af122077860ed806213a8 /components/drivers/wlan/wlan_dev.c | |
| parent | 02722864d6204d1671c8409276a41b78d1d2a9e8 (diff) | |
[driver][wlan] add raw frame send interface and Management frame filter interface
Signed-off-by: chenyong <[email protected]>
Diffstat (limited to 'components/drivers/wlan/wlan_dev.c')
| -rw-r--r-- | components/drivers/wlan/wlan_dev.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c index cbfd50a6c3..4241476a2b 100644 --- a/components/drivers/wlan/wlan_dev.c +++ b/components/drivers/wlan/wlan_dev.c @@ -574,6 +574,77 @@ rt_err_t rt_wlan_dev_report_data(struct rt_wlan_device *device, void *buff, int #endif } +rt_err_t rt_wlan_dev_enter_mgnt_filter(struct rt_wlan_device *device) +{ + rt_err_t result = RT_EOK; + int enable = 1; + + if (device == RT_NULL) + { + return -RT_EIO; + } + + result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_CFG_MGNT_FILTER, &enable); + return result; +} + +rt_err_t rt_wlan_dev_exit_mgnt_filter(struct rt_wlan_device *device) +{ + rt_err_t result = RT_EOK; + int enable = 0; + + if (device == RT_NULL) + { + return -RT_EIO; + } + + result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_CFG_MGNT_FILTER, &enable); + return result; +} + +rt_err_t rt_wlan_dev_set_mgnt_filter_callback(struct rt_wlan_device *device, rt_wlan_mgnt_filter_callback_t callback) +{ + if (device == RT_NULL) + { + return -RT_EIO; + } + device->mgnt_filter_callback = callback; + + return RT_EOK; +} + +void rt_wlan_dev_mgnt_filter_handler(struct rt_wlan_device *device, void *data, int len) +{ + rt_wlan_mgnt_filter_callback_t callback; + + if (device == RT_NULL) + { + return; + } + + callback = device->mgnt_filter_callback; + + if (callback != RT_NULL) + { + callback(device, data, len); + } +} + +int rt_wlan_dev_send_raw_frame(struct rt_wlan_device *device, void *buff, int len) +{ + if (device == RT_NULL) + { + return -RT_EIO; + } + + if (device->ops->wlan_send_raw_frame) + { + return device->ops->wlan_send_raw_frame(device, buff, len); + } + + return -RT_ERROR; +} + static rt_err_t _rt_wlan_dev_init(rt_device_t dev) { struct rt_wlan_device *wlan = (struct rt_wlan_device *)dev; @@ -716,6 +787,15 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args) err = wlan->ops->wlan_cfg_filter(wlan, filter); break; } + case RT_WLAN_CMD_CFG_MGNT_FILTER: + { + rt_bool_t start = *((rt_bool_t *)args); + + LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_CFG_MGNT_FILTER, "RT_WLAN_CMD_CFG_MGNT_FILTER"); + if (wlan->ops->wlan_cfg_mgnt_filter) + err = wlan->ops->wlan_cfg_mgnt_filter(wlan, start); + break; + } case RT_WLAN_CMD_SET_CHANNEL: { int channel = *(int *)args; |
