feat(lwip): Disable IPv6 default

This commit is contained in:
Dong Heng
2018-08-15 16:24:42 +08:00
parent fd63b5e561
commit b1ee72bdbe
5 changed files with 23 additions and 6 deletions

View File

@ -27,6 +27,8 @@
extern "C" { extern "C" {
#endif #endif
#define ESP_EVENT_IPV6 LWIP_IPV6
typedef enum { typedef enum {
SYSTEM_EVENT_WIFI_READY = 0, /**< ESP8266 WiFi ready */ SYSTEM_EVENT_WIFI_READY = 0, /**< ESP8266 WiFi ready */
SYSTEM_EVENT_SCAN_DONE, /**< ESP8266 finish scanning AP */ SYSTEM_EVENT_SCAN_DONE, /**< ESP8266 finish scanning AP */

View File

@ -262,6 +262,7 @@ static esp_err_t esp_system_event_debug(system_event_t *event)
MAC2STR(ap_probereqrecved->mac)); MAC2STR(ap_probereqrecved->mac));
break; break;
} }
#if ESP_EVENT_IPV6
case SYSTEM_EVENT_GOT_IP6: { case SYSTEM_EVENT_GOT_IP6: {
ip6_addr_t *addr = &event->event_info.got_ip6.ip6_info.ip; ip6_addr_t *addr = &event->event_info.got_ip6.ip6_info.ip;
ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STA_GOT_IP6 address %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x", ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STA_GOT_IP6 address %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
@ -275,6 +276,7 @@ static esp_err_t esp_system_event_debug(system_event_t *event)
IP6_ADDR_BLOCK8(addr)); IP6_ADDR_BLOCK8(addr));
break; break;
} }
#endif
default: { default: {
ESP_LOGW(TAG, "unexpected system event %d!", event->event_id); ESP_LOGW(TAG, "unexpected system event %d!", event->event_id);

View File

@ -444,7 +444,7 @@ endmenu # LWIP RAW API
menuconfig LWIP_IPV6 menuconfig LWIP_IPV6
bool "Enable IPv6" bool "Enable IPv6"
default y default n
config LWIP_IPV6_NUM_ADDRESSES config LWIP_IPV6_NUM_ADDRESSES
int "Number of IPv6 addresses per netif" int "Number of IPv6 addresses per netif"

View File

@ -40,6 +40,7 @@
#define CONFIG_TCPIP_LWIP 1 #define CONFIG_TCPIP_LWIP 1
#define CONFIG_DHCP_STA_LIST 1 #define CONFIG_DHCP_STA_LIST 1
#define TCPIP_ADAPTER_IPV6 LWIP_IPV6
#if CONFIG_TCPIP_LWIP #if CONFIG_TCPIP_LWIP
#include "lwip/ip_addr.h" #include "lwip/ip_addr.h"
@ -73,9 +74,17 @@ typedef struct {
ip4_addr_t gw; ip4_addr_t gw;
} tcpip_adapter_ip_info_t; } tcpip_adapter_ip_info_t;
#if TCPIP_ADAPTER_IPV6
typedef struct { typedef struct {
ip6_addr_t ip; ip6_addr_t ip;
} tcpip_adapter_ip6_info_t; } tcpip_adapter_ip6_info_t;
#else
typedef struct {
struct {
uint32_t addr[4];
} ip;
} tcpip_adapter_ip6_info_t;
#endif
typedef dhcps_lease_t tcpip_adapter_dhcps_lease_t; typedef dhcps_lease_t tcpip_adapter_dhcps_lease_t;
@ -349,6 +358,7 @@ esp_err_t tcpip_adapter_set_old_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapt
*/ */
esp_err_t tcpip_adapter_create_ip6_linklocal(tcpip_adapter_if_t tcpip_if); esp_err_t tcpip_adapter_create_ip6_linklocal(tcpip_adapter_if_t tcpip_if);
#if TCPIP_ADAPTER_IPV6
/** /**
* @brief get interface's linkloacl IPv6 information * @brief get interface's linkloacl IPv6 information
* *
@ -362,6 +372,7 @@ esp_err_t tcpip_adapter_create_ip6_linklocal(tcpip_adapter_if_t tcpip_if);
* ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS
*/ */
esp_err_t tcpip_adapter_get_ip6_linklocal(tcpip_adapter_if_t tcpip_if, ip6_addr_t *if_ip6); esp_err_t tcpip_adapter_get_ip6_linklocal(tcpip_adapter_if_t tcpip_if, ip6_addr_t *if_ip6);
#endif
#if 0 #if 0
esp_err_t tcpip_adapter_get_mac(tcpip_adapter_if_t tcpip_if, uint8_t *mac); esp_err_t tcpip_adapter_get_mac(tcpip_adapter_if_t tcpip_if, uint8_t *mac);

View File

@ -596,6 +596,7 @@ static void tcpip_adapter_nd6_cb(struct netif *p_netif, uint8_t ip_idex)
} }
#endif #endif
#if TCPIP_ADAPTER_IPV6
esp_err_t tcpip_adapter_create_ip6_linklocal(tcpip_adapter_if_t tcpip_if) esp_err_t tcpip_adapter_create_ip6_linklocal(tcpip_adapter_if_t tcpip_if)
{ {
struct netif *p_netif; struct netif *p_netif;
@ -632,6 +633,7 @@ esp_err_t tcpip_adapter_get_ip6_linklocal(tcpip_adapter_if_t tcpip_if, ip6_addr_
} }
return ESP_OK; return ESP_OK;
} }
#endif
esp_err_t tcpip_adapter_dhcps_option(tcpip_adapter_option_mode_t opt_op, tcpip_adapter_option_id_t opt_id, void *opt_val, uint32_t opt_len) esp_err_t tcpip_adapter_dhcps_option(tcpip_adapter_option_mode_t opt_op, tcpip_adapter_option_id_t opt_id, void *opt_val, uint32_t opt_len)
{ {
@ -767,13 +769,13 @@ esp_err_t tcpip_adapter_set_dns_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS; return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
} }
if (ip4_addr_isany_val(dns->ip.u_addr.ip4)) { if (ip4_addr_isany_val(*ip_2_ip4(&(dns->ip)))) {
ESP_LOGD(TAG, "set dns invalid dns"); ESP_LOGD(TAG, "set dns invalid dns");
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS; return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
} }
ESP_LOGD(TAG, "set dns if=%d type=%d dns=%x", tcpip_if, type, dns->ip.u_addr.ip4.addr); ESP_LOGD(TAG, "set dns if=%d type=%d dns=%x", tcpip_if, type, ip_2_ip4(&(dns->ip))->addr);
dns->ip.type = IPADDR_TYPE_V4; IP_SET_TYPE_VAL(dns->ip, IPADDR_TYPE_V4)
if (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) { if (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) {
dns_setserver(type, &(dns->ip)); dns_setserver(type, &(dns->ip));
@ -812,7 +814,7 @@ esp_err_t tcpip_adapter_get_dns_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_
ns = dns_getserver(type); ns = dns_getserver(type);
dns->ip = *ns; dns->ip = *ns;
} else { } else {
dns->ip.u_addr.ip4 = dhcps_dns_getserver(); *ip_2_ip4(&(dns->ip)) = dhcps_dns_getserver();
} }
return ESP_OK; return ESP_OK;