File tree 2 files changed +21
-6
lines changed
2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -380,6 +380,10 @@ size_t IPAddress::printTo(Print& p, bool includeZone) const
380
380
return n;
381
381
}
382
382
383
+ IPAddress::IPAddress (const ip_addr_t *addr){
384
+ from_ip_addr_t (addr);
385
+ }
386
+
383
387
void IPAddress::to_ip_addr_t (ip_addr_t * addr) const {
384
388
if (_type == IPv6){
385
389
addr->type = IPADDR_TYPE_V6;
@@ -396,7 +400,7 @@ void IPAddress::to_ip_addr_t(ip_addr_t* addr) const {
396
400
}
397
401
}
398
402
399
- IPAddress& IPAddress::from_ip_addr_t (ip_addr_t * addr){
403
+ IPAddress& IPAddress::from_ip_addr_t (const ip_addr_t * addr){
400
404
if (addr->type == IPADDR_TYPE_V6){
401
405
_type = IPv6;
402
406
_address.dword [0 ] = addr->u_addr .ip6 .addr [0 ];
@@ -413,5 +417,14 @@ IPAddress& IPAddress::from_ip_addr_t(ip_addr_t* addr){
413
417
return *this ;
414
418
}
415
419
420
+ esp_ip6_addr_type_t IPAddress::addr_type (){
421
+ if (_type != IPv6){
422
+ return ESP_IP6_ADDR_IS_UNKNOWN;
423
+ }
424
+ ip_addr_t addr;
425
+ to_ip_addr_t (&addr);
426
+ return esp_netif_ip6_get_addr_type ((esp_ip6_addr_t *)(&(addr.u_addr .ip6 )));
427
+ }
428
+
416
429
const IPAddress IN6ADDR_ANY (IPv6);
417
430
const IPAddress INADDR_NONE (0 ,0 ,0 ,0 );
Original file line number Diff line number Diff line change 23
23
#include " Printable.h"
24
24
#include " WString.h"
25
25
#include " lwip/ip_addr.h"
26
+ #include " esp_netif_ip_addr.h"
26
27
27
28
#define IPADDRESS_V4_BYTES_INDEX 12
28
29
#define IPADDRESS_V4_DWORD_INDEX 3
@@ -93,16 +94,17 @@ class IPAddress : public Printable {
93
94
IPAddress& operator =(const IPAddress& address);
94
95
95
96
virtual size_t printTo (Print& p) const ;
96
- size_t printTo (Print& p, bool includeZone) const ;
97
97
String toString (bool includeZone = false ) const ;
98
98
99
99
IPType type () const { return _type; }
100
100
101
- uint8_t zone () const { return (type () == IPv6)?_zone:0 ; }
102
-
103
- // LwIP conversions
101
+ // Espresif LwIP conversions
102
+ IPAddress (const ip_addr_t *addr);
104
103
void to_ip_addr_t (ip_addr_t * addr) const ;
105
- IPAddress& from_ip_addr_t (ip_addr_t * addr);
104
+ IPAddress& from_ip_addr_t (const ip_addr_t * addr);
105
+ esp_ip6_addr_type_t addr_type ();
106
+ uint8_t zone () const { return (type () == IPv6)?_zone:0 ; }
107
+ size_t printTo (Print& p, bool includeZone) const ;
106
108
107
109
friend class UDP ;
108
110
friend class Client ;
You can’t perform that action at this time.
0 commit comments