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
eth/mac.cpp
- Committer:
- andrewboyson
- Date:
- 2017-05-01
- Revision:
- 13:9cd54f7db57a
- Child:
- 14:e75a59c1123d
File content as of revision 13:9cd54f7db57a:
#include "mbed.h" #include "eth.h" char MacLocal[6]; bool MacCompareBroadcast(char* p) { if (*p++ != 0xff) return false; if (*p++ != 0xff) return false; if (*p++ != 0xff) return false; if (*p++ != 0xff) return false; if (*p++ != 0xff) return false; if (*p != 0xff) return false; return true; } bool MacCompareUnicastLocal(char* p) { return memcmp(p, MacLocal, 6) == 0; } bool MacCompareMulticastLocal4(char* p) { if (*p++ != 0x01) return false; if (*p++ != 0x00) return false; if (*p++ != 0x5e) return false; char* q = MacLocal + 3; if (*p++ != *q++) return false; if (*p++ != *q++) return false; if (*p != *q ) return false; return true; } bool MacCompareMulticastLocal6(char* p) { if (*p++ != 0x33) return false; if (*p++ != 0x33) return false; if (*p++ != 0xff) return false; char* q = MacLocal + 3; if (*p++ != *q++) return false; if (*p++ != *q++) return false; if (*p != *q ) return false; return true; } bool MacCompareMulticastAllNodes4(char* p) { if (*p++ != 0x01) return false; if (*p++ != 0x00) return false; if (*p++ != 0x5e) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p != 0x01) return false; return true; } bool MacCompareMulticastAllNodes6(char* p) { if (*p++ != 0x33) return false; if (*p++ != 0x33) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p != 0x01) return false; return true; } bool MacCompareMulticastAllRouters4(char* p) { if (*p++ != 0x01) return false; if (*p++ != 0x00) return false; if (*p++ != 0x5e) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p != 0x02) return false; return true; } bool MacCompareMulticastAllRouters6(char* p) { if (*p++ != 0x33) return false; if (*p++ != 0x33) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p != 0x02) return false; return true; } bool MacCompareMulticastMdns4(char* p) { if (*p++ != 0x01) return false; if (*p++ != 0x00) return false; if (*p++ != 0x5e) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p != 0xfb) return false; return true; } bool MacCompareMulticastMdns6(char* p) { if (*p++ != 0x33) return false; if (*p++ != 0x33) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p != 0xfb) return false; return true; } bool MacCompareMulticastLlmnr4(char* p) { if (*p++ != 0x01) return false; if (*p++ != 0x00) return false; if (*p++ != 0x5e) return false; if (*p++ != 0x01) return false; if (*p++ != 0x00) return false; if (*p != 0x03) return false; return true; } bool MacCompareMulticastLlmnr6(char* p) { if (*p++ != 0x33) return false; if (*p++ != 0x33) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p++ != 0x00) return false; if (*p != 0xfc) return false; return true; } void MacMakeMulticastNode4(char* p) { *p++ = 0x01; *p++ = 0x00; *p++ = 0x5e; *p++ = 0x00; *p++ = 0x00; *p = 0x01; } void MacMakeMulticastNode6(char* p) { *p++ = 0x33; *p++ = 0x33; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p = 0x01; } void MacMakeMulticastRouter4(char* p) { *p++ = 0x01; *p++ = 0x00; *p++ = 0x5e; *p++ = 0x00; *p++ = 0x00; *p = 0x02; } void MacMakeMulticastRouter6(char* p) { *p++ = 0x33; *p++ = 0x33; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p = 0x02; } void MacMakeMulticastMdns4(char* p) { *p++ = 0x01; *p++ = 0x00; *p++ = 0x5e; *p++ = 0x00; *p++ = 0x00; *p = 0xfb; } void MacMakeMulticastMdns6(char* p) { *p++ = 0x33; *p++ = 0x33; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p = 0xfb; } void MacMakeMulticastLlmnr4(char* p) { *p++ = 0x01; *p++ = 0x00; *p++ = 0x5e; *p++ = 0x00; *p++ = 0x00; *p = 0xfc; } void MacMakeMulticastLlmnr6(char* p) { *p++ = 0x33; *p++ = 0x33; *p++ = 0x00; *p++ = 0x01; *p++ = 0x00; *p = 0x03; } void MacMakeBroadcast(char* p) { memset(p, 0xFF, 6); }