*** esp-idf-v5.2.1.orig/components/esp_netif/include/esp_netif_types.h 2024-03-06 02:41:38.000000000 +0100 --- esp-idf-v5.2.1/components/esp_netif/include/esp_netif_types.h 2024-04-21 11:36:55.552094946 +0200 *************** *** 50,58 **** /** @brief Type of DNS server */ ! typedef enum { ! ESP_NETIF_DNS_MAIN= 0, /**< DNS main server address*/ ! ESP_NETIF_DNS_BACKUP, /**< DNS backup server address (Wi-Fi STA and Ethernet only) */ ESP_NETIF_DNS_FALLBACK, /**< DNS fallback server address (Wi-Fi STA and Ethernet only) */ ESP_NETIF_DNS_MAX } esp_netif_dns_type_t; --- 50,63 ---- /** @brief Type of DNS server */ ! typedef enum ! { ! ESP_NETIF_WIFI_DNS_MAIN = 0, /**< DNS main server address - for WiFi */ ! ESP_NETIF_WIFI_DNS_BACKUP, /**< DNS backup server address - for WiFi */ ! ESP_NETIF_ETH_DNS_MAIN, /**< DNS main server address - for Ethernet */ ! ESP_NETIF_ETH_DNS_BACKUP, /**< DNS backup server address - for Ethernet */ ! ESP_NETIF_PPP_DNS_MAIN, /**< DNS main server address - for mobile service / ppp */ ! ESP_NETIF_PPP_DNS_BACKUP, /**< DNS backup server address - for mobile service / ppp */ ESP_NETIF_DNS_FALLBACK, /**< DNS fallback server address (Wi-Fi STA and Ethernet only) */ ESP_NETIF_DNS_MAX } esp_netif_dns_type_t; *************** *** 200,205 **** --- 205,211 ---- A higher value of route_prio indicates a higher priority */ bridgeif_config_t *bridge_info; /*!< LwIP bridge configuration */ + uint8_t ifdex_dns; } esp_netif_inherent_config_t; typedef struct esp_netif_config esp_netif_config_t; *** esp-idf-v5.2.1.orig/components/esp_netif/include/esp_netif_defaults.h 2024-03-06 02:41:38.000000000 +0100 --- esp-idf-v5.2.1/components/esp_netif/include/esp_netif_defaults.h 2024-04-21 14:39:11.122054905 +0200 *************** *** 46,52 **** .if_key = "WIFI_STA_DEF", \ .if_desc = "sta", \ .route_prio = 100, \ ! .bridge_info = NULL \ } \ #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT --- 46,53 ---- .if_key = "WIFI_STA_DEF", \ .if_desc = "sta", \ .route_prio = 100, \ ! .bridge_info = NULL, \ ! .ifdex_dns = 0 \ } \ #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT *************** *** 60,66 **** .if_key = "WIFI_AP_DEF", \ .if_desc = "ap", \ .route_prio = 10, \ ! .bridge_info = NULL \ } #endif --- 61,68 ---- .if_key = "WIFI_AP_DEF", \ .if_desc = "ap", \ .route_prio = 10, \ ! .bridge_info = NULL, \ ! .ifdex_dns = 10 \ } #endif *************** *** 73,79 **** .lost_ip_event = 0, \ .if_key = "WIFI_NAN_DEF", \ .if_desc = "nan", \ ! .route_prio = 10 \ }; #define ESP_NETIF_INHERENT_DEFAULT_ETH() \ --- 75,82 ---- .lost_ip_event = 0, \ .if_key = "WIFI_NAN_DEF", \ .if_desc = "nan", \ ! .route_prio = 10, \ ! .ifdex_dns = 10 \ }; #define ESP_NETIF_INHERENT_DEFAULT_ETH() \ *************** *** 86,92 **** .if_key = "ETH_DEF", \ .if_desc = "eth", \ .route_prio = 50, \ ! .bridge_info = NULL \ } #ifdef CONFIG_PPP_SUPPORT --- 89,96 ---- .if_key = "ETH_DEF", \ .if_desc = "eth", \ .route_prio = 50, \ ! .bridge_info = NULL, \ ! .ifdex_dns = 2 \ } #ifdef CONFIG_PPP_SUPPORT *************** *** 100,106 **** .if_key = "PPP_DEF", \ .if_desc = "ppp", \ .route_prio = 20, \ ! .bridge_info = NULL \ } #endif /* CONFIG_PPP_SUPPORT */ --- 104,111 ---- .if_key = "PPP_DEF", \ .if_desc = "ppp", \ .route_prio = 20, \ ! .bridge_info = NULL, \ ! .ifdex_dns = ESP_NETIF_PPP_DNS_MAIN \ } #endif /* CONFIG_PPP_SUPPORT */ *************** *** 114,120 **** .if_key = "BR0", \ .if_desc = "br0", \ .route_prio = 70, \ ! .bridge_info = NULL \ } #define ESP_NETIF_INHERENT_DEFAULT_BR_DHCPS() \ --- 119,126 ---- .if_key = "BR0", \ .if_desc = "br0", \ .route_prio = 70, \ ! .bridge_info = NULL, \ ! .ifdex_dns = 70 \ } #define ESP_NETIF_INHERENT_DEFAULT_BR_DHCPS() \ *************** *** 127,133 **** .if_key = "BR1", \ .if_desc = "br1", \ .route_prio = 70, \ ! .bridge_info = NULL \ } /** --- 133,140 ---- .if_key = "BR1", \ .if_desc = "br1", \ .route_prio = 70, \ ! .bridge_info = NULL, \ ! .ifdex_dns = 70 \ } /** *************** *** 184,189 **** --- 191,198 ---- .driver = NULL, \ .stack = ESP_NETIF_NETSTACK_DEFAULT_PPP, \ } + // .base = ESP_NETIF_BASE_DEFAULT_PPP, + // .base = ESP_NETIF_INHERENT_DEFAULT_PPP(), #endif /* CONFIG_PPP_SUPPORT */ /** *** esp-idf-v5.2.1.orig/components/esp_netif/lwip/esp_netif_lwip.c 2024-03-06 02:41:38.000000000 +0100 --- esp-idf-v5.2.1/components/esp_netif/lwip/esp_netif_lwip.c 2024-04-21 17:08:45.528693599 +0200 *************** *** 630,635 **** --- 630,636 ---- } #endif // CONFIG_ESP_NETIF_BRIDGE_EN + esp_netif->ifdex_dns = cfg->base->ifdex_dns; // Install network stack functions -- connects netif and L3 stack const esp_netif_netstack_config_t *esp_netif_stack_config = cfg->stack; if (cfg->base->flags & ESP_NETIF_FLAG_IS_PPP) { *************** *** 1431,1436 **** --- 1432,1438 ---- continue; } + ESP_LOGI("esp_netif_lwip", "%s dns_setserver(%d, 0)", __FUNCTION__, numdns); dns_setserver(numdns, NULL); } } *************** *** 1455,1461 **** esp_netif_reset_ip_info(esp_netif); #if LWIP_DNS ! dns_clear_servers(true); #endif if (p_netif != NULL) { --- 1457,1467 ---- esp_netif_reset_ip_info(esp_netif); #if LWIP_DNS ! //dns_clear_servers(true); ! ESP_LOGI("esp_netif_lwip", "%s dns_setserver(%d, 0)", __FUNCTION__, esp_netif->ifdex_dns); ! dns_setserver(esp_netif->ifdex_dns, NULL); ! ESP_LOGI("esp_netif_lwip", "%s dns_setserver(%d, 0)", __FUNCTION__, esp_netif->ifdex_dns + 1); ! dns_setserver(esp_netif->ifdex_dns + 1, NULL); #endif if (p_netif != NULL) { *************** *** 1684,1689 **** --- 1690,1699 ---- if (esp_netif->flags & ESP_NETIF_DHCP_CLIENT && esp_netif->dhcpc_status == ESP_NETIF_DHCP_STARTED) { #if CONFIG_LWIP_IPV4 dhcp_stop(esp_netif->lwip_netif); + ESP_LOGI("esp_netif_lwip", "%s dns_setserver(%d, 0)", __FUNCTION__, esp_netif->ifdex_dns); + dns_setserver(esp_netif->ifdex_dns, NULL); + ESP_LOGI("esp_netif_lwip", "%s dns_setserver(%d, 0)", __FUNCTION__, esp_netif->ifdex_dns + 1); + dns_setserver(esp_netif->ifdex_dns + 1, NULL); esp_netif->dhcpc_status = ESP_NETIF_DHCP_INIT; *************** *** 1804,1809 **** --- 1814,1820 ---- { esp_netif_t *esp_netif = msg->esp_netif; const esp_netif_ip_info_t *ip_info = msg->data; + struct netif *p_netif = esp_netif->lwip_netif; ESP_LOGD(TAG, "%s esp_netif:%p", __func__, esp_netif); *************** *** 1820,1826 **** return ESP_ERR_ESP_NETIF_DHCP_NOT_STOPPED; } #if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ ! dns_clear_servers(true); #endif } --- 1831,1841 ---- return ESP_ERR_ESP_NETIF_DHCP_NOT_STOPPED; } #if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ ! //dns_clear_servers(true); ! ESP_LOGI("esp_netif_lwip", "%s dns_setserver(%d, 0)", __FUNCTION__, esp_netif->ifdex_dns); ! dns_setserver(esp_netif->ifdex_dns, NULL); ! ESP_LOGI("esp_netif_lwip", "%s dns_setserver(%d, 0)", __FUNCTION__, esp_netif->ifdex_dns + 1); ! dns_setserver(esp_netif->ifdex_dns + 1, NULL); #endif } *************** *** 1828,1835 **** ip4_addr_copy(esp_netif->ip_info->gw, ip_info->gw); ip4_addr_copy(esp_netif->ip_info->netmask, ip_info->netmask); - struct netif *p_netif = esp_netif->lwip_netif; - if (p_netif != NULL && netif_is_up(p_netif)) { netif_set_addr(p_netif, (ip4_addr_t*)&ip_info->ip, (ip4_addr_t*)&ip_info->netmask, (ip4_addr_t*)&ip_info->gw); if (ESP_NETIF_FLAG_EVENT_IP_MODIFIED & esp_netif->flags) { --- 1843,1848 ---- *************** *** 1904,1920 **** ESPIP_TO_IP(&dns->ip, &lwip_ip); if (esp_netif->flags & ESP_NETIF_DHCP_SERVER) { #if ESP_DHCPS ! // if DHCP server configured to set DNS in dhcps API ! if (type != ESP_NETIF_DNS_MAIN) { ! ESP_LOGD(TAG, "set dns invalid type"); ! return ESP_ERR_ESP_NETIF_INVALID_PARAMS; ! } else { ! dhcps_dns_setserver(esp_netif->dhcps, &lwip_ip); ! } #else LOG_NETIF_DISABLED_AND_DO("DHCP Server", return ESP_ERR_NOT_SUPPORTED); #endif } else { dns_setserver(type, &lwip_ip); } --- 1917,1929 ---- ESPIP_TO_IP(&dns->ip, &lwip_ip); if (esp_netif->flags & ESP_NETIF_DHCP_SERVER) { #if ESP_DHCPS ! ESP_LOGI("esp_netif_lwip", "%s dns_setserver(%d, %s)", __FUNCTION__, type, inet_ntoa(dns->ip)); ! dns_setserver(type, &lwip_ip); #else LOG_NETIF_DISABLED_AND_DO("DHCP Server", return ESP_ERR_NOT_SUPPORTED); #endif } else { + ESP_LOGI("esp_netif_lwip", "%s dns_setserver(%d, %s)", __FUNCTION__, type, inet_ntoa(dns->ip)); dns_setserver(type, &lwip_ip); } *** esp-idf-v5.2.1.orig/components/esp_netif/lwip/esp_netif_lwip_internal.h 2024-03-06 02:41:38.000000000 +0100 --- esp-idf-v5.2.1/components/esp_netif/lwip/esp_netif_lwip_internal.h 2024-04-21 11:01:08.272324200 +0200 *************** *** 112,115 **** --- 112,117 ---- uint16_t max_fdb_sta_entries; uint8_t max_ports; #endif // CONFIG_ESP_NETIF_BRIDGE_EN + + u8_t ifdex_dns; }; *** esp-idf-v5.2.1.orig/components/lwip/Kconfig 2024-03-06 02:41:38.000000000 +0100 --- esp-idf-v5.2.1/components/lwip/Kconfig 2024-04-21 18:18:23.927054881 +0200 *************** *** 1052,1059 **** config LWIP_DNS_MAX_SERVERS int "Maximum number of DNS servers" ! default 3 ! range 1 4 help Set maximum number of DNS servers. If fallback DNS servers are supported, --- 1052,1059 ---- config LWIP_DNS_MAX_SERVERS int "Maximum number of DNS servers" ! default 6 ! range 1 16 help Set maximum number of DNS servers. If fallback DNS servers are supported, *** esp-idf-v5.2.1.orig/components/lwip/port/include/lwipopts.h 2024-03-06 02:41:38.000000000 +0100 --- esp-idf-v5.2.1/components/lwip/port/include/lwipopts.h 2024-04-21 16:42:11.025244322 +0200 *************** *** 473,478 **** --- 473,480 ---- /** The maximum of DNS servers */ #define DNS_MAX_SERVERS CONFIG_LWIP_DNS_MAX_SERVERS + #define DNS_WIFI_SERVER_START_INDEX 0 + #define DNS_ETH_SERVER_START_INDEX 2 /** ESP specific option only applicable if ESP_DNS=1 * *************** *** 1585,1590 **** --- 1587,1593 ---- #define ESP_THREAD_PROTECTION 1 #define LWIP_SUPPORT_CUSTOM_PBUF 1 #define ESP_LWIP_FALLBACK_DNS_PREFER_IPV4 0 + #define ESP_MULTIPLE_DNS 1 /* ----------------------------------------- *** esp-idf-v5.2.1.orig/components/lwip/lwip/src/core/ipv6/nd6.c 2024-03-06 02:42:30.000000000 +0100 --- esp-idf-v5.2.1/components/lwip/lwip/src/core/ipv6/nd6.c 2024-04-21 17:48:35.985731551 +0200 *************** *** 780,785 **** --- 780,786 ---- if (htonl(rdnss_opt->lifetime) > 0) { /* TODO implement Lifetime > 0 */ + ESP_LOGI("nd6", "%s dns_setserver(%d, _)", __FUNCTION__, rdnss_server_idx); dns_setserver(rdnss_server_idx++, &rdnss_address); } else { /* TODO implement DNS removal in dns.c */ *************** *** 787,792 **** --- 788,794 ---- for (s = 0; s < DNS_MAX_SERVERS; s++) { const ip_addr_t *addr = dns_getserver(s); if(ip_addr_cmp(addr, &rdnss_address)) { + ESP_LOGI("nd6", "%s dns_setserver(%d, 0)", __FUNCTION__, s); dns_setserver(s, NULL); } } *** esp-idf-v5.2.1.orig/components/lwip/lwip/src/core/ipv6/dhcp6.c 2024-03-06 02:42:30.000000000 +0100 --- esp-idf-v5.2.1/components/lwip/lwip/src/core/ipv6/dhcp6.c 2024-04-21 17:49:28.666816518 +0200 *************** *** 547,552 **** --- 547,553 ---- } ip6_addr_assign_zone(dns_addr6, IP6_UNKNOWN, netif); /* @todo: do we need a different offset than DHCP(v4)? */ + ESP_LOGI("dhcp6", "%s dns_setserver(%d, _)", __FUNCTION__, n); dns_setserver(n, &dns_addr); } } *** esp-idf-v5.2.1.orig/components/lwip/lwip/src/core/ipv4/dhcp.c 2024-03-06 02:42:30.000000000 +0100 --- esp-idf-v5.2.1/components/lwip/lwip/src/core/ipv4/dhcp.c 2024-04-21 17:35:29.329489070 +0200 *************** *** 83,88 **** --- 83,93 ---- #include + #if ESP_MULTIPLE_DNS + #include + #include + #endif + #if ESP_LWIP_DHCP_FINE_TIMERS_ONDEMAND #include #define ESP_LWIP_DHCP_FINE_TIMER_START_ONCE(netif, dhcp) if(!dhcp->fine_timer_enabled) { \ *************** *** 776,783 **** --- 781,807 ---- continue; } #endif + #if ESP_MULTIPLE_DNS + if (n >= 2) { + break; + } + ip_addr_set_ip4_u32_val(dns_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n))); + if(netif->name[0] == 's' && netif->name[1] == 't') { + if (!ip_addr_isany(&dns_addr)) { + ESP_LOGI("dhcp", "%s dns_setserver(%d, %s)", __FUNCTION__, DNS_WIFI_SERVER_START_INDEX + n, inet_ntoa(dns_addr)); + dns_setserver(DNS_WIFI_SERVER_START_INDEX + n, &dns_addr); + } + } else if(netif->name[0] == 'e' && netif->name[1] == 'n') { + if (!ip_addr_isany(&dns_addr)) { + ESP_LOGI("dhcp", "%s dns_setserver(%d, %s)", __FUNCTION__, DNS_ETH_SERVER_START_INDEX + n, inet_ntoa(dns_addr)); + dns_setserver(DNS_ETH_SERVER_START_INDEX + n, &dns_addr); + } + } + #else ip_addr_set_ip4_u32_val(dns_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n))); + ESP_LOGI("dhcp", "%s dns_setserver(%d, %s)", __FUNCTION__, n, inet_ntoa(dns_addr)); dns_setserver(n, &dns_addr); + #endif /* ESP_MULTIPLE_DNS */ } #endif /* LWIP_DHCP_PROVIDE_DNS_SERVERS */ } *** esp-idf-v5.2.1.orig/components/lwip/lwip/src/netif/ppp/ppp.c 2024-03-06 02:42:30.000000000 +0100 --- esp-idf-v5.2.1/components/lwip/lwip/src/netif/ppp/ppp.c 2024-04-21 17:46:39.323327765 +0200 *************** *** 135,140 **** --- 135,143 ---- #include "netif/ppp/ipv6cp.h" #endif /* PPP_IPV6_SUPPORT */ + #include + #include + /*************************/ /*** LOCAL DEFINITIONS ***/ /*************************/ *************** *** 1104,1109 **** --- 1107,1124 ---- #endif /* UNUSED - PROXY ARP */ #if LWIP_DNS + // Duplicate from esp_netif_types.h , I'm sure there's a better way to do this but including esp_netif in lwip doesn't seem right either. + typedef enum + { + ESP_NETIF_WIFI_DNS_MAIN = 0, /**< DNS main server address - for WiFi */ + ESP_NETIF_WIFI_DNS_BACKUP, /**< DNS backup server address - for WiFi */ + ESP_NETIF_ETH_DNS_MAIN, /**< DNS main server address - for Ethernet */ + ESP_NETIF_ETH_DNS_BACKUP, /**< DNS backup server address - for Ethernet */ + ESP_NETIF_PPP_DNS_MAIN, /**< DNS main server address - for mobile service / ppp */ + ESP_NETIF_PPP_DNS_BACKUP, /**< DNS backup server address - for mobile service / ppp */ + ESP_NETIF_DNS_FALLBACK, /**< DNS fallback server address (Wi-Fi STA and Ethernet only) */ + ESP_NETIF_DNS_MAX + } esp_netif_dns_type_t; /* * sdns - Config the DNS servers */ *************** *** 1112,1120 **** LWIP_UNUSED_ARG(pcb); ip_addr_set_ip4_u32_val(ns, ns1); ! dns_setserver(0, &ns); ip_addr_set_ip4_u32_val(ns, ns2); ! dns_setserver(1, &ns); return 1; } --- 1127,1137 ---- LWIP_UNUSED_ARG(pcb); ip_addr_set_ip4_u32_val(ns, ns1); ! ESP_LOGI("ppp", "%s dns_setserver(%d, %s)", __FUNCTION__, ESP_NETIF_PPP_DNS_MAIN, inet_ntoa(ns)); ! dns_setserver(ESP_NETIF_PPP_DNS_MAIN, &ns); ip_addr_set_ip4_u32_val(ns, ns2); ! ESP_LOGI("ppp", "%s dns_setserver(%d, %s)", __FUNCTION__, ESP_NETIF_PPP_DNS_BACKUP, inet_ntoa(ns)); ! dns_setserver(ESP_NETIF_PPP_DNS_BACKUP, &ns); return 1; } *************** *** 1130,1141 **** nsa = dns_getserver(0); ip_addr_set_ip4_u32_val(nsb, ns1); if (ip_addr_cmp(nsa, &nsb)) { ! dns_setserver(0, IP_ADDR_ANY); } nsa = dns_getserver(1); ip_addr_set_ip4_u32_val(nsb, ns2); if (ip_addr_cmp(nsa, &nsb)) { ! dns_setserver(1, IP_ADDR_ANY); } return 1; } --- 1147,1160 ---- nsa = dns_getserver(0); ip_addr_set_ip4_u32_val(nsb, ns1); if (ip_addr_cmp(nsa, &nsb)) { ! ESP_LOGI("ppp", "%s dns_setserver(%d, ANY)", __FUNCTION__, ESP_NETIF_PPP_DNS_MAIN); ! dns_setserver(ESP_NETIF_PPP_DNS_MAIN, IP_ADDR_ANY); } nsa = dns_getserver(1); ip_addr_set_ip4_u32_val(nsb, ns2); if (ip_addr_cmp(nsa, &nsb)) { ! ESP_LOGI("ppp", "%s dns_setserver(%d, ANY)", __FUNCTION__, ESP_NETIF_PPP_DNS_BACKUP); ! dns_setserver(ESP_NETIF_PPP_DNS_BACKUP, IP_ADDR_ANY); } return 1; }