28 #include "user_config.h" 33 #define WIFI_SCAN_INTERVAL 5000 34 #define WIFI_SCAN_TIMEOUT 60000 35 #define RSSI_CHECK_INTERVAL 10000 101 nif->napt = nat ? 1 : 0;
102 if (nif->
input != ifn) {
116 struct eth_hdr *mac_h;
119 struct udp_hdr *udp_h;
120 struct tcp_hdr *tcp_h;
121 uint16_t src_port = 0;
122 uint16_t dest_port = 0;
125 if (p->
len <
sizeof(
struct eth_hdr)) {
129 mac_h = (
struct eth_hdr *)p->
payload;
132 if (
ntohs(mac_h->type) == ETHTYPE_ARP) {
137 if (
ntohs(mac_h->type) != ETHTYPE_IP) {
141 if (p->
len <
sizeof(
struct eth_hdr)+
sizeof(
struct ip_hdr)) {
146 ip_h = (
struct ip_hdr *)&packet[
sizeof(
struct eth_hdr)];
151 if (p->
len <
sizeof(
struct eth_hdr)+
sizeof(
struct ip_hdr)+
sizeof(
struct udp_hdr)) {
154 udp_h = (
struct udp_hdr *)&packet[
sizeof(
struct eth_hdr)+
sizeof(
struct ip_hdr)];
155 src_port =
ntohs(udp_h->src);
156 dest_port =
ntohs(udp_h->dest);
160 if (p->
len <
sizeof(
struct eth_hdr)+
sizeof(
struct ip_hdr)+
sizeof(
struct tcp_hdr)) {
163 tcp_h = (
struct tcp_hdr *)&packet[
sizeof(
struct eth_hdr)+
sizeof(
struct ip_hdr)];
164 src_port =
ntohs(tcp_h->src);
165 dest_port =
ntohs(tcp_h->dest);
169 src_port = dest_port = 0;
179 if ((ip_h->dest.addr ==
dns_ip.addr) && (dest_port == 53)) {
186 os_printf(
"dropping packet to uplink network: src: %d.%d.%d.%d dst: %d.%d.%d.%d proto: %s sport:%d dport:%d\n",
218 switch (evt->
event) {
235 os_printf(
"reconnecting on disconnect\n");
296 os_printf(
"wifi_station_scan() returned false, restarting scanner\n");
328 if ((arg !=
NULL) && (status ==
OK)) {
332 while (info !=
NULL) {
345 info = info->next.stqe_next;
440 INFO(
"WIFI_INIT\r\n");
531 dns_ip = dns_getserver(0);
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
ICACHE_FLASH_ATTR err_t my_output_ap(struct netif *outp, struct pbuf *p)
void wifi_handle_event_cb(System_Event_t *evt)
volatile bool wifi_fallback_present
void(* wifi_scan_result_event_cb_t)(const struct bss_info *info)
void ICACHE_FLASH_ATTR wifi_fallback()
bool wifi_set_opmode_current(uint8 opmode)
static void ICACHE_FLASH_ATTR wifi_scan_timeout_timer_func(void *arg)
volatile uint8_t * config_pass
volatile bool my_auto_connect
sint8_t ICACHE_FLASH_ATTR wifi_get_rssi()
void ICACHE_FLASH_ATTR wifi_softap_config(uint8_t *ssid, uint8_t *pass, uint8_t authmode)
struct netif * netif_list
#define WIFI_SCAN_TIMEOUT
void espconn_dns_setserver(u8_t numdns, ip_addr_t *dnsserver)
Event_SoftAPMode_StaConnected_t sta_connected
void ICACHE_FLASH_ATTR wifi_start_scan()
void ICACHE_FLASH_ATTR wifi_scan_done_cb(void *arg, STATUS status)
bool wifi_softap_dhcps_stop(void)
#define ICACHE_FLASH_ATTR
volatile bool wifi_scan_runnning
volatile bool wifi_default_ok
bool wifi_station_get_config(struct station_config *config)
void ICACHE_FLASH_ATTR wifi_connect(uint8_t *ssid, uint8_t *pass, WifiCallback cb)
uint8 wifi_station_get_connect_status(void)
uint8_t ICACHE_FLASH_ATTR UTILS_StrToIP(const int8_t *str, void *ip)
void wifi_scan_result_cb_register(wifi_scan_result_event_cb_t cb)
bool wifi_softap_get_config(struct softap_config *config)
static ip_addr_t ap_network_addr
static void ICACHE_FLASH_ATTR wifi_scan_timer_func(void *arg)
static ip_addr_t sta_network_addr
bool wifi_station_set_config(struct station_config *config)
bool ICACHE_FLASH_ATTR wifi_fallback_is_present()
void ICACHE_FLASH_ATTR wifi_stop_scan()
#define STA_FALLBACK_SSID
#define ip_addr_cmp(addr1, addr2)
void ICACHE_FLASH_ATTR set_my_auto_connect(bool enabled)
bool wifi_softap_dhcps_start(void)
bool wifi_fallback_last_present
bool wifi_set_ip_info(uint8 if_index, struct ip_info *info)
static netif_linkoutput_fn orig_output_ap
ICACHE_FLASH_ATTR err_t my_input_ap(struct pbuf *p, struct netif *inp)
wifi_scan_result_event_cb_t wifi_scan_result_cb
void(* WifiCallback)(uint8_t)
static ICACHE_FLASH_ATTR void patch_netif_ap(netif_input_fn ifn, netif_linkoutput_fn ofn, bool nat)
bool ICACHE_FLASH_ATTR wifi_get_status()
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
bool ICACHE_FLASH_ATTR wifi_softap_set_dhcps_lease(struct dhcps_lease *please)
void wifi_set_event_handler_cb(wifi_event_handler_cb_t cb)
static netif_input_fn orig_input_ap
static os_timer_t wifi_scan_timeout_timer
#define WIFI_SCAN_INTERVAL
static os_timer_t wifi_scan_timer
static os_timer_t wifi_get_rssi_timer
#define ip4_addr3(ipaddr)
bool wifi_station_disconnect(void)
volatile bool get_rssi_running
u8_t pbuf_free(struct pbuf *p) ICACHE_FLASH_ATTR
bool wifi_station_set_auto_connect(uint8 set)
volatile uint8_t * config_ssid
ICACHE_FLASH_ATTR int tfp_snprintf(char *str, size_t size, const char *format,...)
sint8 wifi_station_get_rssi(void)
static void ICACHE_FLASH_ATTR wifi_get_rssi_timer_func(void *arg)
bool wifi_station_scan(struct scan_config *config, scan_done_cb_t cb)
bool wifi_station_set_config_current(struct station_config *config)
#define os_timer_arm(a, b, c)
bool ICACHE_FLASH_ATTR wifi_scan_is_running()
ICACHE_FLASH_ATTR void led_pattern_a(void)
Event_StaMode_Disconnected_t disconnected
bool ICACHE_FLASH_ATTR acl_check_packet(struct pbuf *p)
bool wifi_softap_set_config(struct softap_config *config)
#define STA_FALLBACK_PASS
static uint8_t wifi_status
#define ip4_addr4(ipaddr)
ICACHE_FLASH_ATTR void led_stop_pattern(void)
void ICACHE_FLASH_ATTR wifi_default()
#define RSSI_CHECK_INTERVAL
netif_linkoutput_fn linkoutput
void ICACHE_FLASH_ATTR wifi_softap_ip_config(void)
err_t(* netif_linkoutput_fn)(struct netif *netif, struct pbuf *p)
bool wifi_station_connect(void)
void wifi_scan_result_cb_unregister(wifi_scan_result_event_cb_t cb)
void dhcps_set_DNS(struct ip_addr *dns_ip) ICACHE_FLASH_ATTR
static uint8_t wifi_event
static ip_addr_t sta_network_mask
#define IP4_ADDR(ipaddr, a, b, c, d)
Event_StaMode_Got_IP_t got_ip