Skip to content

Commit 20630d0

Browse files
authored
Bring back IPv6 zones
by @s-hadinger
1 parent bf9deb1 commit 20630d0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cores/esp32/IPAddress.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ bool IPAddress::fromString6(const char *address) {
201201
colons++;
202202
acc = 0;
203203
} else if (c == '%') {
204-
_zone = netif_name_to_index(address);
204+
// netif_index_to_name crashes on latest esp-idf
205+
// _zone = netif_name_to_index(address);
206+
// in the interim, we parse the suffix as a zone number
207+
while ((*address != '\0') && (!isdigit(*address))) { // skip all non-digit after '%'
208+
address++;
209+
}
210+
_zone = atol(address);
205211
while (*address != '\0') {
206212
address++;
207213
}
@@ -351,6 +357,11 @@ size_t IPAddress::printTo(Print &p, bool includeZone) const {
351357
// netif_index_to_name(_zone, if_name);
352358
// n += p.print(if_name);
353359
// }
360+
// In the interim, we just output the index number
361+
if (_zone > 0 && includeZone) {
362+
n += p.print('%');
363+
n += p.print(_zone);
364+
}
354365
return n;
355366
}
356367

0 commit comments

Comments
 (0)