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

@ -56,6 +56,7 @@ uint32_t sdk_system_relative_time(uint32_t reltime);
uint32_t sdk_system_get_checksum(uint8_t *, uint32_t);
void sdk_wifi_softap_cacl_mac(uint8_t *, uint8_t *);
void sdk_wifi_softap_set_default_ssid(void);
bool sdk_wifi_softap_set_station_info(const uint8_t *hwaddr, ip4_addr_t *);
// xtensa_context.o

View file

@ -32,7 +32,7 @@ struct esf_buf *sdk_ieee80211_getmgtframe(void **arg0, uint32_t arg1, uint32_t a
extern uint8_t sdk_TmpSTAAPCloseAP;
extern uint8_t sdk_PendFreeBcnEb;
void sdk_ieee80211_hostap_attach(struct sdk_g_ic_st *);
void sdk_hostap_handle_timer(struct sdk_netif_conninfo *cnx_node);
void sdk_hostap_handle_timer(struct sdk_cnx_node *cnx_node);
bool sdk_wifi_softap_start();
bool sdk_wifi_softap_stop();
@ -85,10 +85,10 @@ int sdk_chm_check_same_channel();
extern ETSTimer sdk_sta_con_timer;
extern void *sdk_g_cnx_probe_rc_list_cb;
void sdk_cnx_sta_leave(struct sdk_g_ic_netif_info *netif_info, void *);
void *sdk_cnx_node_search(uint8_t mac[6]);
void sdk_cnx_node_leave(struct sdk_g_ic_netif_info *netif, struct sdk_netif_conninfo *conn);
struct sdk_cnx_node *sdk_cnx_node_search(uint8_t mac[6]);
void sdk_cnx_node_leave(struct sdk_g_ic_netif_info *netif, struct sdk_cnx_node *conn);
void sdk_cnx_rc_update_state_metric(void *, int, int);
void sdk_cnx_remove_rc(void *);
void sdk_cnx_node_remove(struct sdk_cnx_node *cnx_node);
void sdk_cnx_attach(struct sdk_g_ic_st *);
#endif /* _ESPLIBS_LIBNET80211_H */

View file

@ -23,6 +23,7 @@ extern uint8_t sdk_interface_mask;
void sdk_ic_set_vif(int, int, uint8_t (*)[6], int, int);
void sdk_ic_bss_info_update(int, uint8_t (*hwaddr)[], int, int);
void sdk_ic_set_sta(int, int, void *, int, int, int, int, int);
void sdk_ic_remove_key(uint32_t);
// lmac.o
extern uint32_t sdk_lmacConfMib;

View file

@ -53,6 +53,7 @@ int sdk_os_get_random(uint8_t *dst, uint32_t size);
// wpa_auth.o
uint32_t *sdk_wpa_init(uint8_t (*hwaddr)[], struct _unknown_wpa1 *, int);
void sdk_wpa_auth_sta_deinit(void *);
// wpabuf.o

View file

@ -6,6 +6,10 @@
// useful for quickly troubleshooting whether a bug is due to the
// reimplementation of Espressif libraries, or something else.
// Some source code is mandatory and these are not included as options here.
// For example code referencing lwip structures and flags etc that has changed
// since the initial binary code.
#ifndef OPEN_ESPLIBS
#define OPEN_ESPLIBS 1
#endif
@ -32,8 +36,8 @@
#ifndef OPEN_LIBMAIN_XTENSA_CONTEXT
#define OPEN_LIBMAIN_XTENSA_CONTEXT (OPEN_LIBMAIN)
#endif
#ifndef OPEN_LIBMAIN_USER_INTERFACE
#define OPEN_LIBMAIN_USER_INTERFACE (OPEN_LIBMAIN)
#ifndef OPEN_LIBMAIN_ETS_TIMER
#define OPEN_LIBMAIN_ETS_TIMER (OPEN_LIBMAIN)
#endif
#ifndef OPEN_LIBNET80211
@ -42,18 +46,6 @@
#ifndef OPEN_LIBNET80211_ETS
#define OPEN_LIBNET80211_ETS (OPEN_LIBNET80211)
#endif
#ifndef OPEN_LIBNET80211_HOSTAP
#define OPEN_LIBNET80211_HOSTAP (OPEN_LIBNET80211)
#endif
#ifndef OPEN_LIBNET80211_INPUT
#define OPEN_LIBNET80211_INPUT (OPEN_LIBNET80211)
#endif
#ifndef OPEN_LIBNET80211_STA
#define OPEN_LIBNET80211_STA (OPEN_LIBNET80211)
#endif
#ifndef OPEN_LIBNET80211_WL_CNX
#define OPEN_LIBNET80211_WL_CNX (OPEN_LIBNET80211)
#endif
#ifndef OPEN_LIBPHY
#define OPEN_LIBPHY (OPEN_ESPLIBS)
@ -115,8 +107,4 @@
#define OPEN_LIBWPA_OS_XTENSA (OPEN_LIBWPA)
#endif
#ifndef OPEN_LIBWPA_WPA_MAIN
#define OPEN_LIBWPA_WPA_MAIN (OPEN_LIBWPA)
#endif
#endif /* _OPEN_ESPLIBS_H */

View file

@ -3,9 +3,6 @@
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_LIBMAIN_USER_INTERFACE
// The contents of this file are only built if OPEN_LIBMAIN_USER_INTERFACE is set to true
#include "FreeRTOS.h"
#include "task.h"
@ -147,8 +144,8 @@ bool IRAM sdk_system_rtc_mem_read(uint32_t src_addr, void *des_addr, uint16_t sa
return true;
}
void sdk_system_pp_recycle_rx_pkt(void *eb) {
sdk_ppRecycleRxPkt(eb);
void sdk_system_pp_recycle_rx_pkt(struct esf_buf *esf_buf) {
sdk_ppRecycleRxPkt(esf_buf);
}
uint16_t sdk_system_adc_read(void) {
@ -471,8 +468,7 @@ uint32_t sdk_system_relative_time(uint32_t reltime) {
return WDEV.SYS_TIME - reltime;
}
// Change arg types to ip4_addr for lwip v2.
void sdk_system_station_got_ip_set(struct ip_addr *ip, struct ip_addr *mask, struct ip_addr *gw) {
void sdk_system_station_got_ip_set(struct ip4_addr *ip, struct ip4_addr *mask, struct ip4_addr *gw) {
uint8_t *ip_bytes = (uint8_t *)&ip->addr;
uint8_t *mask_bytes = (uint8_t *)&mask->addr;
uint8_t *gw_bytes = (uint8_t *)&gw->addr;
@ -588,9 +584,9 @@ bool sdk_wifi_get_ip_info(uint8_t if_index, struct ip_info *info) {
if (!info) return false;
struct netif *netif = _get_netif(if_index);
if (netif) {
info->ip = netif->ip_addr;
info->netmask = netif->netmask;
info->gw = netif->gw;
ip4_addr_set(&info->ip, ip_2_ip4(&netif->ip_addr));
ip4_addr_set(&info->netmask, ip_2_ip4(&netif->netmask));
ip4_addr_set(&info->gw, ip_2_ip4(&netif->gw));
return true;
}
@ -719,5 +715,3 @@ bool sdk_wifi_set_sleep_type(enum sdk_sleep_type type)
sdk_pm_set_sleep_type_from_upper(type);
return true;
}
#endif /* OPEN_LIBMAIN_USER_INTERFACE */

View file

@ -3,8 +3,306 @@
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_HOSTAP
// The contents of this file are only built if OPEN_LIBNET80211_HOSTAP is set to true
#endif /* OPEN_LIBNET80211_HOSTAP */
#include <string.h>
#include "tcpip.h"
#include "espressif/esp_wifi.h"
#include "espressif/esp_misc.h"
#include "etstimer.h"
#include "esplibs/libmain.h"
#include "esplibs/libnet80211.h"
#include "esplibs/libpp.h"
#include "esplibs/libwpa.h"
static uint8_t hostap_flags = 0;
static ETSTimer hostap_timer;
static struct esf_buf *hostap_timer_parg = NULL;
void IRAM *zalloc(size_t nbytes);
static void IRAM hostap_timer_func(struct esf_buf *esf_buf) {
struct sdk_cnx_node *cnx_node = sdk_g_ic.v.softap_netif_info->cnx_nodes[0];
int32_t mode = sdk_wifi_get_phy_mode();
uint8_t *frame = esf_buf->frame;
*(uint16_t *)(frame + 22) = (cnx_node->_unknown9c - 1) << 4;
cnx_node->_unknown9c += 1;
if (sdk_g_ic.s.wifi_led_enable) {
uint32_t gpio = sdk_g_ic.s.wifi_led_gpio;
uint32_t state = sdk_g_ic.s.wifi_led_state;
sdk_gpio_output_set(state << gpio, (((state & 1) == 0) ? 1 : 0) << gpio,
1 << gpio, 0);
sdk_g_ic.s.wifi_led_state = (state & 1) ? 0 : 1;
}
uint8_t *frame2 = frame + sdk_g_ic.s._unknown288 + (mode == 1 ? 23 : 27) ;
memcpy(frame2 + 29, &sdk_g_ic.v._unknown1d2, 1);
uint32_t v1 = frame2[26];
if (v1 == 0) {
v1 = frame2[27];
}
frame2[26] = v1 - 1;
uint32_t v2 = sdk_ieee80211_chan2ieee(sdk_g_ic.v._unknown14c);
frame2[23] = v2;
sdk_g_ic.s._unknown30d = v2;
int32_t v3 = *((volatile int32_t *)0x3ff20c00); // mactime
*(uint32_t *)(esf_buf->extra + 16) = v3;
*(uint32_t *)(frame + 24) = v3;
*(uint32_t *)(frame + 28) = 0;
if (sdk_chm_check_same_channel()) {
hostap_flags |= 1;
sdk_ppTxPkt(esf_buf);
return;
}
sdk_ets_timer_disarm(&hostap_timer);
sdk_ets_timer_arm(&hostap_timer, sdk_wDev_Get_Next_TBTT(), 0);
}
static void IRAM hostap_tx_callback() {
uint32_t flags = hostap_flags & 0xfe;
if (sdk_TmpSTAAPCloseAP == 0) {
hostap_flags = flags;
sdk_ets_timer_disarm(&hostap_timer);
sdk_ets_timer_arm(&hostap_timer, sdk_wDev_Get_Next_TBTT(), 0);
return;
}
sdk_PendFreeBcnEb = 1;
if (flags & 2) {
hostap_flags = flags & 0xfd;
sdk_wifi_softap_start();
return;
}
hostap_flags = flags;
}
static void hostap_attach_misc() {
struct sdk_g_ic_netif_info *netif_info = sdk_g_ic.v.softap_netif_info;
struct _unknown_softap1 *ptr1 = zalloc(28); // 0x1c
netif_info->_unknownb4 = ptr1;
struct _unknown_softap2 *ptr2 = zalloc(204); // 0xcc
ptr1->_unknown04 = ptr2;
struct _unknown_wpa1 *ptr3 = zalloc(76); // 0x4c
uint32_t v1 = sdk_g_ic.s._unknown30e;
if (v1 == 2) {
ptr3->_unknown00 = 1;
} else if (v1 == 3) {
ptr3->_unknown00 = 2;
} else if (v1 == 4) {
ptr3->_unknown00 = 3;
}
ptr3->_unknown28 = 2;
ptr3->_unknown04 = 2;
ptr3->_unknown0c = 2;
ptr3->_unknown08 = 10;
ptr3->_unknown20 = 10;
int s1 = (sdk_g_ic.s._unknown28a << 16) | sdk_g_ic.s._unknown288;
memcpy(&ptr2->_unknown10, &sdk_g_ic.s._unknown28c, s1);
ptr2->_unknown30 = s1;
uint8_t *ptr4 = zalloc(64); // 0x40
ptr2->_unknown3c = ptr4;
char *str1 = sdk_g_ic.s._unknown2ac;
memcpy(ptr4, str1, strlen(str1));
struct sdk_cnx_node *cnx_node = netif_info->cnx_nodes[0];
ptr2->_unknownb4 = 300;
netif_info->_unknown4c = 3;
netif_info->_unknown48 |= 16;
cnx_node->_unknown08 |= 1;
sdk_hostapd_setup_wpa_psk(ptr2);
struct netif *netif = netif_info->netif;
ptr1->_unknown18 = sdk_wpa_init(&netif->hwaddr, ptr3, 0);
free(ptr3);
}
static void softap_stop_free() {
struct sdk_g_ic_netif_info *netif_info = sdk_g_ic.v.softap_netif_info;
netif_info->_unknown4c = 0;
netif_info->_unknown48 &= 0xffffffef;
netif_info->cnx_nodes[0]->_unknown08 = 0;
struct _unknown_softap1 *unkb4 = netif_info->_unknownb4;
if (!unkb4) return;
uint32_t *unk18 = unkb4->_unknown18;
if (unk18) {
uint32_t *ptr1 = ((uint32_t **)unk18)[20];
if (ptr1)
free(ptr1);
uint32_t *ptr2 = *(uint32_t **)unk18;
if (ptr2)
free(ptr2);
free(unk18);
}
struct _unknown_softap2 *unk04 = unkb4->_unknown04;
if (unk04) {
uint32_t *unk38 = unk04->_unknown38;
if (unk38)
free(unk38);
uint8_t *unk3c = unk04->_unknown3c;
if (unk3c)
free(unk3c);
free(unk04);
}
free(unkb4);
netif_info->_unknownb4 = NULL;
}
void sdk_ieee80211_hostap_attach(struct sdk_g_ic_st *ic) {
uint32_t scratch[12]; // ??
struct sdk_g_ic_netif_info *netif_info = ic->v.softap_netif_info;
uint32_t v1 = ic->s._unknown30e;
if (v1 >= 2 && v1 < 5)
hostap_attach_misc();
struct netif *netif = netif_info->netif;
sdk_ic_bss_info_update(1, &netif->hwaddr, 2, 100);
ic->v._unknown1d0 = 0;
netif_info->_unknown3c = 5;
sdk_ppRegisterTxCallback(hostap_tx_callback, 4);
hostap_timer_parg = sdk_ieee80211_beacon_alloc(netif_info, scratch);
sdk_ets_timer_disarm(&hostap_timer);
sdk_ets_timer_setfn(&hostap_timer, (ETSTimerFunc *)hostap_timer_func, hostap_timer_parg);
sdk_wDev_Reset_TBTT();
sdk_ets_timer_arm(&hostap_timer, sdk_wDev_Get_Next_TBTT(), 0);
}
bool sdk_wifi_softap_start() {
struct sdk_g_ic_netif_info *netif_info = sdk_g_ic.v.softap_netif_info;
if (!netif_info) return 0;
if (netif_info->started) return 1;
uint8_t flags = hostap_flags;
if (flags & 1) {
hostap_flags = flags | 2;
return 1;
}
uint8_t (*mac_addr)[6] = &sdk_info.softap_mac_addr;
if (!netif_info->netif) {
struct netif *netif = (struct netif *)malloc(sizeof(struct netif));
netif_info->netif = netif;
memcpy(&netif->hwaddr, mac_addr, 6);
netif_add(netif, &sdk_info.softap_ipaddr, &sdk_info.softap_netmask,
&sdk_info.softap_gw, netif_info, ethernetif_init, tcpip_input);
}
sdk_ic_set_vif(1, 1, mac_addr, 1, 0);
netif_set_up(netif_info->netif);
if (sdk_wifi_get_opmode() != 3 ||
!sdk_g_ic.v.station_netif_info ||
sdk_g_ic.v.station_netif_info->_unknown3c < 2) {
uint32_t i1 = (sdk_g_ic.s._unknown30d - 1) & 0xff;
int nmi_on = sdk_NMIIrqIsOn;
if (!nmi_on) {
vPortEnterCritical();
do {
DPORT.DPORT0 = DPORT.DPORT0 & 0xffffffe0;
} while (DPORT.DPORT0 & 1);
}
// current channel?
uint32_t *chan = &sdk_g_ic.v._unknown84[i1 * 3];
sdk_g_ic.v._unknown14c = chan;
if (!nmi_on) {
DPORT.DPORT0 = (DPORT.DPORT0 & 0xffffffe0) | 1;
vPortExitCritical();
}
sdk_chm_set_current_channel(chan);
}
sdk_ieee80211_hostap_attach(&sdk_g_ic);
sdk_TmpSTAAPCloseAP = 0;
netif_info->started = 1;
return 1;
}
bool sdk_wifi_softap_stop() {
struct sdk_g_ic_netif_info *netif_info = sdk_g_ic.v.softap_netif_info;
if (!netif_info)
return 0;
if (!netif_info->started)
return 1;
uint32_t end = sdk_g_ic.s._unknown310 + 2;
uint32_t count = 1;
// Note this defensive test seems dead code, the value is loaded
// as a uint8_t value so adding 2 ensures this test always passes.
if (end >= 2) {
do {
struct sdk_cnx_node *cnx_node = netif_info->cnx_nodes[count];
if (cnx_node) {
struct sdk_cnx_node *cnx_node2 = netif_info->_unknown88;
netif_info->_unknown88 = cnx_node;
sdk_ieee80211_send_mgmt(netif_info, 160, 4);
sdk_ieee80211_send_mgmt(netif_info, 192, 2);
netif_info->_unknown88 = cnx_node2;
sdk_cnx_node_leave(netif_info, netif_info->cnx_nodes[count]);
// Number of entries might have changed, perhaps
// should have if one was removed above?
end = sdk_g_ic.s._unknown310 + 2;
}
count++;
} while (count < end);
}
netif_set_down(netif_info->netif);
sdk_TmpSTAAPCloseAP = 1;
sdk_ets_timer_disarm(&hostap_timer);
sdk_ic_bss_info_update(1, &sdk_info.softap_mac_addr, 2, 0);
sdk_ic_set_vif(1, 0, NULL, 1, 0);
softap_stop_free();
if ((hostap_flags & 1) == 0)
sdk_esf_buf_recycle(hostap_timer_parg, 4);
netif_info->started = 0;
return 1;
}

View file

@ -3,9 +3,6 @@
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_INPUT
// The contents of this file are only built if OPEN_LIBNET80211_INPUT is set to true
#include "esplibs/libpp.h"
@ -14,10 +11,9 @@ void IRAM sdk_ieee80211_deliver_data(struct sdk_g_ic_netif_info *netif_info, str
if (netif->flags & NETIF_FLAG_LINK_UP) {
uint16_t length = esf_buf->length;
struct pbuf *pbuf = pbuf_alloc(PBUF_RAW, length, PBUF_REF);
pbuf->payload = esf_buf->pbuf2->payload;
struct pbuf *pbuf = pbuf_alloc_reference(esf_buf->pbuf2->payload, length, PBUF_ALLOC_FLAG_RX | PBUF_TYPE_ALLOC_SRC_MASK_ESP_RX);
esf_buf->pbuf1 = pbuf;
pbuf->eb = (void *)esf_buf;
pbuf->esf_buf = (void *)esf_buf;
ethernetif_input(netif, pbuf);
return;
}
@ -27,5 +23,3 @@ void IRAM sdk_ieee80211_deliver_data(struct sdk_g_ic_netif_info *netif_info, str
return;
}
#endif /* OPEN_LIBNET80211_INPUT */

View file

@ -3,9 +3,6 @@
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_STA
// The contents of this file are only built if OPEN_LIBNET80211_STA is set to true
#include <string.h>
#include "esplibs/libmain.h"
@ -72,5 +69,3 @@ bool sdk_wifi_station_stop() {
return 1;
}
#endif /* OPEN_LIBNET80211_STA */

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 */

View file

@ -5,7 +5,13 @@
*/
#include "open_esplibs.h"
#if OPEN_LIBPP_WDEV
// The contents of this file are only built if OPEN_LIBPHY_PHY_CHIP_SLEEP is set to true
// The contents of this file are only built if OPEN_LIBPP_WDEV is set to true
// Note the SDK allocated 8000 bytes for TX buffers that appears to be
// unused. Rather TX buffers appear to be allocated by upper layers. The
// location of this areas is at wDevCtrl + 0x2190. The SDK has been modified
// to allocate only one word (4 bytes) per buffer on initialization and even
// these seem unused but to be sure avoid the first 20 bytes. So there are
// 7980 bytes free starting at wDevCtrl + 0x21a4.
#endif /* OPEN_LIBPP_WDEV */

View file

@ -3,13 +3,13 @@
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_LIBWPA_WPA_MAIN
// The contents of this file are only built if OPEN_LIBWPA_WPA_MAIN is set to true
#include <strings.h>
#include <string.h>
#include "espressif/user_interface.h"
#include "etstimer.h"
#include "espressif/osapi.h"
#include "espressif/esp_sta.h"
#include "esplibs/libnet80211.h"
#include "esplibs/libmain.h"
#include "esplibs/libwpa.h"
@ -44,8 +44,8 @@ void sdk_wpa_config_bss(struct sdk_g_ic_st *g_ic, uint8_t (* hwaddr2)[6]) {
struct sdk_g_ic_netif_info *netif_info = g_ic->v.station_netif_info;
struct netif *netif = netif_info->netif;
sdk_wpa_set_bss(netif->hwaddr, hwaddr2, g_ic->s._unknown20a, g_ic->s._unknown20c,
g_ic->s.sta_password, g_ic->s._unknown1e4.sta_ssid,
(g_ic->s._unknown1e4._unknown1e6 << 16) | g_ic->s._unknown1e4._unknown1e4);
g_ic->s.sta_password, g_ic->s.sta_ssid.ssid,
g_ic->s.sta_ssid.ssid_length);
}
void sdk_wpa_config_assoc_ie(int arg0, int16_t *arg1, int32_t arg2) {
@ -57,14 +57,14 @@ void sdk_wpa_config_assoc_ie(int arg0, int16_t *arg1, int32_t arg2) {
*arg1 = arg2;
}
void sdk_dhcp_bind_check() {
void sdk_dhcp_bind_check(void *parg) {
struct sdk_g_ic_netif_info *netif_info = sdk_g_ic.v.station_netif_info;
uint8_t connect_status = netif_info->connect_status;
uint8_t unknown20a = sdk_g_ic.s._unknown20a;
if (connect_status != 5) {
if (connect_status != STATION_GOT_IP) {
if (unknown20a == 7 || unknown20a == 8) {
netif_info->connect_status = 2;
netif_info->connect_status = STATION_CONNECTING;
}
}
}
@ -72,13 +72,13 @@ void sdk_dhcp_bind_check() {
void sdk_eagle_auth_done() {
struct sdk_g_ic_netif_info *netif_info = sdk_g_ic.v.station_netif_info;
struct netif *netif = netif_info->netif;
struct sdk_netif_conninfo *conninfo = netif_info->_unknown88;
struct sdk_cnx_node *cnx_node = netif_info->_unknown88;
if (conninfo->_unknown08 & 1)
if (cnx_node->_unknown08 & 1)
return;
uint32_t channel = conninfo->_unknown78->channel;
char *ssid = (char *)sdk_g_ic.s._unknown1e4.sta_ssid;
uint32_t channel = cnx_node->_unknown78->channel;
char *ssid = (char *)sdk_g_ic.s.sta_ssid.ssid;
printf("\nconnected with %s, channel %d\n", ssid, channel);
RTCMEM_SYSTEM[61] = 0x00010000 | channel;
@ -89,24 +89,29 @@ void sdk_eagle_auth_done() {
sdk_os_timer_arm(timer, 15000, 0);
netif_info->statusb9 = 0;
conninfo->_unknown18 = 0;
conninfo->_unknown08 |= 1;
cnx_node->_unknown18 = 0;
cnx_node->_unknown08 |= 1;
// TODO lwip v2 removed the NETIF_FLAG_DHCP flag.
if (netif->flags & 0x08) // NETIF_FLAG_DHCP
if (dhcp_supplied_address(netif))
return;
// lwip v2: if (ip4_addr_isany_val(netif->ip_addr)) {
if (netif->ip_addr.addr == 0) {
if (sdk_dhcpc_flag != DHCP_STOPPED) {
printf("dhcp client start...\n");
dhcp_start(netif);
}
if (sdk_dhcpc_flag != DHCP_STOPPED) {
printf("dhcp client start...\n");
netif_set_up(netif);
dhcp_start(netif);
return;
}
system_station_got_ip_set(&netif->ip_addr, &netif->netmask, &netif->gw);
if (ip4_addr_isany_val(sdk_info.sta_ipaddr)) {
printf("expected a static ip address?\n");
return;
}
netif_set_addr(netif, &sdk_info.sta_ipaddr, &sdk_info.sta_netmask, &sdk_info.sta_gw);
netif_set_up(netif);
sdk_system_station_got_ip_set(ip_2_ip4(&netif->ip_addr),
ip_2_ip4(&netif->netmask),
ip_2_ip4(&netif->gw));
}
void sdk_wpa_neg_complete() {
@ -120,5 +125,3 @@ void sdk_wpa_attach(struct sdk_g_ic_st *g_ic) {
wpa_callback2, sdk_wpa_neg_complete);
sdk_ppRegisterTxCallback(sdk_eapol_txcb, 3);
}
#endif /* OPEN_LIBWPA_WPA_MAIN */