瀏覽代碼

IP4 class: ensure it really is an IPv4 address

Make sure we don't accidentally get confused by IPv6 addresses
returned by DNS queries.
H. Peter Anvin 1 年之前
父節點
當前提交
0aaa831586
共有 5 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      esp32/max80/IP4.h
  2. 二進制
      esp32/output/max80.ino.bin
  3. 二進制
      fpga/output/max80.fw
  4. 二進制
      fpga/output/v1.fw
  5. 二進制
      fpga/output/v2.fw

+ 4 - 2
esp32/max80/IP4.h

@@ -24,8 +24,10 @@ public:
     constexpr IP4(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) :
 	b{b0,b1,b2,b3} { }
     IP4(const IPAddress & ip) : l{ip} { }
-    constexpr IP4(const ip_addr_t & ip) : l{ip.u_addr.ip4.addr} { }
-    constexpr IP4(const esp_ip_addr_t & ip) : l{ip.u_addr.ip4.addr} { }
+    constexpr IP4(const ip_addr_t & ip) :
+	l{ip.type == IPADDR_TYPE_V4 ? ip.u_addr.ip4.addr : 0} { }
+    constexpr IP4(const esp_ip_addr_t & ip) :
+	l{ip.type == IPADDR_TYPE_V4 ? ip.u_addr.ip4.addr : 0} { }
     IP4(const char *str);
 
     operator uint32_t () { return l; }

二進制
esp32/output/max80.ino.bin


二進制
fpga/output/max80.fw


二進制
fpga/output/v1.fw


二進制
fpga/output/v2.fw