A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.
Dependents: oldheating gps motorhome heating
Diff: ip6/ip6addr.c
- Revision:
- 136:8a65abb0dc63
- Parent:
- 121:bc048b65a630
- Child:
- 143:8cec8f08dc54
--- a/ip6/ip6addr.c Sat Mar 23 12:25:48 2019 +0000 +++ b/ip6/ip6addr.c Sat Apr 06 11:20:20 2019 +0000 @@ -131,6 +131,43 @@ memcpy(ipTo, ipFrom, 16); } +bool Ip6AddrIsSolicited(char* p) +{ + if (*p++ != 0xff) return false; + if (*p++ != 0x02) return false; + + if (*p++ != 0x00) return false; + if (*p++ != 0x00) return false; + + if (*p++ != 0x00) return false; + if (*p++ != 0x00) return false; + + if (*p++ != 0x00) return false; + if (*p++ != 0x00) return false; + + if (*p++ != 0x00) return false; + if (*p++ != 0x00) return false; + + if (*p++ != 0x00) return false; + if (*p++ != 0x01) return false; + + if (*p++ != 0xff) return false; + + return true; +} +bool Ip6AddrIsMulticast(char *p) +{ + return *p == 0xFF; +} +bool Ip6AddrIsSameGroup(char* pA, char* pB) +{ + pA += 13; + pB += 13; + if (*pA++ != *pB++) return false; + if (*pA++ != *pB++) return false; + return *pA == *pB; +} + const char Ip6AddressAllNodes [] = {0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; const char Ip6AddressAllRouters[] = {0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}; const char Ip6AddressMdns [] = {0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb};