Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: ip6/ip6addr.c
- Revision:
- 193:47a953ab571b
- Parent:
- 187:122fc1996c86
--- a/ip6/ip6addr.c Fri Jan 22 13:24:08 2021 +0000
+++ b/ip6/ip6addr.c Sun Jan 24 15:09:55 2021 +0000
@@ -54,6 +54,58 @@
*p = 0;
return p - pText;
}
+void Ip6AddrParse(const char *pText, char *address) //Contains an empty address if invalid
+{
+ int field = 0;
+ int word = 0;
+ while(true)
+ {
+ switch (*pText)
+ {
+ case ':':
+ address[field] = (word >> 8) & 0xFF;
+ field++;
+ if (field > 15) { address[0] = 0; return; }
+ address[field] = word & 0xFF;
+ field++;
+ if (field > 15) { address[0] = 0; return; }
+ word = 0;
+ break;
+ case '0': word <<= 4; word |= 0; break;
+ case '1': word <<= 4; word |= 1; break;
+ case '2': word <<= 4; word |= 2; break;
+ case '3': word <<= 4; word |= 3; break;
+ case '4': word <<= 4; word |= 4; break;
+ case '5': word <<= 4; word |= 5; break;
+ case '6': word <<= 4; word |= 6; break;
+ case '7': word <<= 4; word |= 7; break;
+ case '8': word <<= 4; word |= 8; break;
+ case '9': word <<= 4; word |= 9; break;
+ case 'a':
+ case 'A': word <<= 4; word |= 10; break;
+ case 'b':
+ case 'B': word <<= 4; word |= 11; break;
+ case 'c':
+ case 'C': word <<= 4; word |= 12; break;
+ case 'd':
+ case 'D': word <<= 4; word |= 13; break;
+ case 'e':
+ case 'E': word <<= 4; word |= 14; break;
+ case 'f':
+ case 'F': word <<= 4; word |= 15; break;
+ case 0:
+ address[field] = (word >> 8) & 0xFF;
+ field++;
+ if (field != 15) { address[0] = 0; return; }
+ address[field] = word & 0xFF;
+ return;
+ default:
+ address[0] = 0;
+ return;
+ }
+ pText++;
+ }
+}
static void logHexNibble(bool* pAdded, int number, int index)
{
int nibble = number;