1 // Copyright 2019 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <string.h>
16 #include "esp_netif.h"
17 #include "esp_netif_sta_list.h"
18 #include "dhcpserver/dhcpserver.h"
19 #include "esp_log.h"
20 
21 #if CONFIG_ESP_NETIF_TCPIP_LWIP
22 
23 static const char *TAG = "esp_netif_sta_list";
24 
esp_netif_get_sta_list(const wifi_sta_list_t * wifi_sta_list,esp_netif_sta_list_t * netif_sta_list)25 esp_err_t esp_netif_get_sta_list(const wifi_sta_list_t *wifi_sta_list, esp_netif_sta_list_t *netif_sta_list)
26 {
27     ESP_LOGD(TAG, "%s entered", __func__);
28 
29     if ((wifi_sta_list == NULL) || (netif_sta_list == NULL)) {
30         return ESP_ERR_ESP_NETIF_INVALID_PARAMS;
31     }
32 
33     memset(netif_sta_list, 0, sizeof(esp_netif_sta_list_t));
34     netif_sta_list->num = wifi_sta_list->num;
35     for (int i = 0; i < wifi_sta_list->num; i++) {
36         memcpy(netif_sta_list->sta[i].mac, wifi_sta_list->sta[i].mac, 6);
37         dhcp_search_ip_on_mac(netif_sta_list->sta[i].mac, (ip4_addr_t*)&netif_sta_list->sta[i].ip);
38     }
39 
40     return ESP_OK;
41 }
42 
43 #endif // CONFIG_ESP_NETIF_TCPIP_LWIP
44