LwIP v2 support

This commit is contained in:
Our Air Quality 2017-06-06 12:47:21 +10:00
parent 1cfded6389
commit cd23acaa4a
39 changed files with 1357 additions and 664 deletions

View file

@ -3,18 +3,29 @@
Copyright (C) 2015 Espressif Systems. Derived from MIT Licensed SDK libraries.
BSD Licensed as described in the file LICENSE
*/
#include "open_esplibs.h"
#if OPEN_LIBNET80211_WL_CNX
// The contents of this file are only built if OPEN_LIBNET80211_WL_CNX is set to true
#include "espressif/esp_misc.h"
#include "esplibs/libnet80211.h"
#include "esplibs/libpp.h"
#include "esplibs/libwpa.h"
#include <string.h>
#include "lwip/dhcp.h"
ETSTimer sdk_sta_con_timer;
void *sdk_g_cnx_probe_rc_list_cb;
/*
* Called from the ESP sdk_cnx_sta_leave function. Split out via a hack to the
* binary library to allow modification to track changes to lwip, for example
* changes to the offset of the netif->flags removal of the NETIF_FLAG_DHCP flag
* lwip v2 etc.
*/
void dhcp_if_down(struct netif *netif)
{
dhcp_release_and_stop(netif);
netif_set_down(netif);
}
#if 0
// Most of the code in this file assesses static data so it will be all or none.
@ -24,7 +35,6 @@ static uint8_t Ldata004;
static uint32_t Ldata006;
static void *Ldate007;
// Use of the netif->flags and the NETIF_FLAG_DHCP flag removed in lwip v2.
void sdk_cnx_sta_leave(struct sdk_g_ic_netif_info *netif_info, void *arg1) {
struct netif *netif = netif_info->netif;
@ -32,13 +42,9 @@ void sdk_cnx_sta_leave(struct sdk_g_ic_netif_info *netif_info, void *arg1) {
uint16_t v1 = *(uint16_t *)(arg1 + 0x1a) & 0xfff;
sdk_ic_set_sta(0, 0, arg1, 0, v1, phy_type, 0, 0);
netif_set_down(netif);
// The NETIF_FLAG_DHCP flags is removed in lwip v2?
if (netif->flags & 0x8) {
dhcp_release(netif);
dhcp_stop(netif);
}
// Note the SDK binary was modified here as it made use of the
// netif flags which changed in lwip v2.
dhcp_if_down(netif);
uint32_t v2 = *(uint8_t *)(arg1 + 0xe8);
free(sdk_g_ic.v._unknown190[v2]);
@ -77,7 +83,30 @@ void sdk_cnx_sta_leave(struct sdk_g_ic_netif_info *netif_info, void *arg1) {
}
#endif
void IRAM *sdk_cnx_node_search(uint8_t mac[6])
void sdk_cnx_node_remove(struct sdk_cnx_node *cnx_node) {
const uint32_t num = sdk_g_ic.s._unknown310 + 2;
if ((int32_t)num < (int32_t)2) {
return;
}
struct sdk_g_ic_netif_info *netif_info = sdk_g_ic.v.softap_netif_info;
uint32_t i = 1;
do {
if (netif_info->cnx_nodes[i] == cnx_node) {
uint32_t v2 = cnx_node->_unknowne8;
sdk_ic_remove_key(v2 + 2);
sdk_wpa_auth_sta_deinit(cnx_node->_unknowne4);
free(sdk_g_ic.v._unknown190[v2]);
sdk_g_ic.v._unknown190[v2] = NULL;
free(cnx_node);
netif_info->cnx_nodes[i] = NULL;
return;
}
i += 1;
} while (i < num);
}
struct sdk_cnx_node *sdk_cnx_node_search(uint8_t mac[6])
{
int end = sdk_g_ic.s._unknown310 + 2;
@ -86,15 +115,15 @@ void IRAM *sdk_cnx_node_search(uint8_t mac[6])
if (end < 1)
return NULL;
struct sdk_netif_conninfo **conninfo = sdk_g_ic.v.softap_netif_info->conninfo;
struct sdk_cnx_node **cnx_nodes = sdk_g_ic.v.softap_netif_info->cnx_nodes;
int i = 0;
do {
struct sdk_netif_conninfo *info = conninfo[i];
struct sdk_cnx_node *cnx_node = cnx_nodes[i];
if (info) {
if (memcmp(mac, info->mac_addr, 6) == 0) {
return info;
if (cnx_node) {
if (memcmp(mac, cnx_node->mac_addr, 6) == 0) {
return cnx_node;
}
}
i++;
@ -102,5 +131,3 @@ void IRAM *sdk_cnx_node_search(uint8_t mac[6])
return NULL;
}
#endif /* OPEN_LIBNET80211_WL_CNX */