File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 24
24
25
25
26
26
27
+ static bool ipv6_is_valid (const char *addr)
28
+ {
29
+ // Check each digit for [0-9a-fA-F:]
30
+ // Must also have at least 2 colons
31
+ int colons = 0 ;
32
+ for (int i = 0 ; addr[i]; i++) {
33
+ if (!(addr[i] >= ' 0' && addr[i] <= ' 9' ) &&
34
+ !(addr[i] >= ' a' && addr[i] <= ' f' ) &&
35
+ !(addr[i] >= ' A' && addr[i] <= ' F' ) &&
36
+ addr[i] != ' :' ) {
37
+ return false ;
38
+ }
39
+ if (addr[i] == ' :' ) {
40
+ colons++;
41
+ }
42
+ }
43
+
44
+ return colons >= 2 ;
45
+ }
46
+
27
47
SocketAddress::SocketAddress (nsapi_addr_t addr, uint16_t port)
28
48
{
29
49
_ip_address = NULL ;
@@ -62,6 +82,7 @@ bool SocketAddress::set_ip_address(const char *addr)
62
82
return true ;
63
83
} else if (addr && stoip6 (addr, strlen (addr), _addr.bytes )) {
64
84
_addr.version = NSAPI_IPv6;
85
+ stoip6 (addr, strlen (addr), _addr.bytes );
65
86
return true ;
66
87
} else {
67
88
_addr = nsapi_addr_t ();
You can’t perform that action at this time.
0 commit comments