@@ -145,7 +145,6 @@ NetworkInterface::NetworkInterface()
145
145
, _got_ip_event_id (-1 )
146
146
, _lost_ip_event_id (-1 )
147
147
, _interface_id (ESP_NETIF_ID_MAX)
148
- , _is_server_if (false )
149
148
{}
150
149
151
150
NetworkInterface::~NetworkInterface (){
@@ -247,11 +246,10 @@ void NetworkInterface::destroyNetif() {
247
246
}
248
247
}
249
248
250
- bool NetworkInterface::initNetif (Network_Interface_ID interface_id, bool server_interface ) {
249
+ bool NetworkInterface::initNetif (Network_Interface_ID interface_id) {
251
250
if (_esp_netif == NULL || interface_id >= ESP_NETIF_ID_MAX){
252
251
return false ;
253
252
}
254
- _is_server_if = server_interface;
255
253
_interface_id = interface_id;
256
254
_got_ip_event_id = esp_netif_get_event_id (_esp_netif, ESP_NETIF_IP_EVENT_GOT_IP);
257
255
_lost_ip_event_id = esp_netif_get_event_id (_esp_netif, ESP_NETIF_IP_EVENT_LOST_IP);
@@ -308,7 +306,8 @@ bool NetworkInterface::dnsIP(uint8_t dns_no, IPAddress ip)
308
306
if (_esp_netif == NULL || dns_no > 2 ){
309
307
return false ;
310
308
}
311
- if (_is_server_if && dns_no > 0 ){
309
+ esp_netif_flags_t flags = esp_netif_get_flags (_esp_netif);
310
+ if (flags & ESP_NETIF_DHCP_SERVER && dns_no > 0 ){
312
311
log_e (" Server interfaces can have only one DNS server." );
313
312
return false ;
314
313
}
@@ -356,7 +355,8 @@ bool NetworkInterface::config(IPAddress local_ip, IPAddress gateway, IPAddress s
356
355
d3.ip .u_addr .ip4 .addr = 0 ;
357
356
}
358
357
359
- if (_is_server_if){
358
+ esp_netif_flags_t flags = esp_netif_get_flags (_esp_netif);
359
+ if (flags & ESP_NETIF_DHCP_SERVER){
360
360
// Stop DHCPS
361
361
err = esp_netif_dhcps_stop (_esp_netif);
362
362
if (err && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED){
@@ -646,7 +646,7 @@ IPAddress NetworkInterface::dnsIP(uint8_t dns_no) const
646
646
}
647
647
if (d.ip .type == ESP_IPADDR_TYPE_V6){
648
648
// IPv6 from 4x uint32_t; byte order based on IPV62STR() in esp_netif_ip_addr.h
649
- log_d (" DNS got IPv6: " IPV6STR, IPV62STR (d.ip .u_addr .ip6 ));
649
+ // log_v ("DNS got IPv6: " IPV6STR, IPV62STR(d.ip.u_addr.ip6));
650
650
uint32_t addr0 esp_netif_htonl (d.ip .u_addr .ip6 .addr [0 ]);
651
651
uint32_t addr1 esp_netif_htonl (d.ip .u_addr .ip6 .addr [1 ]);
652
652
uint32_t addr2 esp_netif_htonl (d.ip .u_addr .ip6 .addr [2 ]);
@@ -672,7 +672,7 @@ IPAddress NetworkInterface::dnsIP(uint8_t dns_no) const
672
672
);
673
673
}
674
674
// IPv4 from single uint32_t
675
- log_d (" DNS IPv4: " IPSTR, IP2STR (&d.ip .u_addr .ip4 ));
675
+ // log_v ("DNS IPv4: " IPSTR, IP2STR(&d.ip.u_addr.ip4));
676
676
return IPAddress (d.ip .u_addr .ip4 .addr );
677
677
}
678
678
@@ -738,6 +738,12 @@ IPAddress NetworkInterface::globalIPv6() const
738
738
739
739
size_t NetworkInterface::printTo (Print & out) const {
740
740
size_t bytes = 0 ;
741
+ if (_esp_netif == NULL ){
742
+ return bytes;
743
+ }
744
+ if (isDefault ()){
745
+ bytes += out.print (" *" );
746
+ }
741
747
const char * dscr = esp_netif_get_desc (_esp_netif);
742
748
if (dscr != NULL ){
743
749
bytes += out.print (dscr);
@@ -749,7 +755,24 @@ size_t NetworkInterface::printTo(Print & out) const {
749
755
bytes += out.print (" <DOWN" );
750
756
}
751
757
bytes += printDriverInfo (out);
752
- bytes += out.println (" >" );
758
+ bytes += out.print (" >" );
759
+
760
+ bytes += out.print (" (" );
761
+ esp_netif_flags_t flags = esp_netif_get_flags (_esp_netif);
762
+ if (flags & ESP_NETIF_DHCP_CLIENT){
763
+ bytes += out.print (" DHCPC" );
764
+ if (getStatusBits () & ESP_NETIF_HAS_STATIC_IP_BIT){
765
+ bytes += out.print (" _OFF" );
766
+ }
767
+ }
768
+ if (flags & ESP_NETIF_DHCP_SERVER) bytes += out.print (" DHCPS" );
769
+ if (flags & ESP_NETIF_FLAG_AUTOUP) bytes += out.print (" ,AUTOUP" );
770
+ if (flags & ESP_NETIF_FLAG_GARP) bytes += out.print (" ,GARP" );
771
+ if (flags & ESP_NETIF_FLAG_EVENT_IP_MODIFIED) bytes += out.print (" ,IP_MOD" );
772
+ if (flags & ESP_NETIF_FLAG_IS_PPP) bytes += out.print (" ,PPP" );
773
+ if (flags & ESP_NETIF_FLAG_IS_BRIDGE) bytes += out.print (" ,BRIDGE" );
774
+ if (flags & ESP_NETIF_FLAG_MLDV6_REPORT) bytes += out.print (" ,V6_REP" );
775
+ bytes += out.println (" )" );
753
776
754
777
bytes += out.print (" " );
755
778
bytes += out.print (" ether " );
0 commit comments