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

Revision:
183:ee809769bf89
Parent:
176:7eb916c22084
Child:
186:24198369b198
--- a/ip4/ip4addr.c	Sun Jan 10 11:52:19 2021 +0000
+++ b/ip4/ip4addr.c	Tue Jan 12 19:10:22 2021 +0000
@@ -61,3 +61,11 @@
             break;
     }
 }
+bool Ip4AddrIsRoutable(uint32_t ip)
+{
+    if ((ip & DhcpSubnetMask) == (DhcpLocalIp & DhcpSubnetMask)) return false; // Ip is same as local ip in the unmasked area
+    if ( ip == (DhcpLocalIp | 0xFF000000)                      ) return false; // Ip == 192.168.0.255; '|' is lower precendence than '=='
+    if ( ip ==  IP4_BROADCAST_ADDRESS                          ) return false; // dstIp == 255.255.255.255
+    if ((ip & 0xE0) == 0xE0                                    ) return false; // 224.x.x.x == 1110 0000 == E0.xx.xx.xx == xx.xx.xx.E0 in little endian
+    return true;
+}
\ No newline at end of file