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: eth/mac.cpp
- Revision:
- 47:73af5c0b0dc2
- Parent:
- 37:793b39683406
- Child:
- 49:1a6336f2b3f9
diff -r 40d33e9037e4 -r 73af5c0b0dc2 eth/mac.cpp --- a/eth/mac.cpp Tue Oct 24 07:01:35 2017 +0000 +++ b/eth/mac.cpp Thu Oct 26 14:50:24 2017 +0000 @@ -1,7 +1,9 @@ #include "mbed.h" +#include "log.h" #include "net.h" #include "action.h" #include "eth.h" +#include "http-reply.h" char MacLocal[6]; void MacClear(char* mac) @@ -31,6 +33,14 @@ { return snprintf(text, size, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } +int MacLog(char* mac) +{ + return LogF("%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); +} +int MacHttp(char* mac) +{ + return HttpReplyAddF("%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); +} int MacAccept(char* p) { @@ -122,12 +132,13 @@ } } -void MacMake(int action, int pro, char* p) +void MacMakeFromDest(int dest, int pro, char* p) { - if (action == BROADCAST) { *p++ = 0xff; *p++ = 0xff; *p++ = 0xff; *p++ = 0xff; *p++ = 0xff; *p = 0xff; return; } + if (dest == BROADCAST) { *p++ = 0xff; *p++ = 0xff; *p++ = 0xff; *p++ = 0xff; *p++ = 0xff; *p = 0xff; return; } + if (pro == IPV4) { - switch (action) + switch (dest) { case MULTICAST_NODE: *p++ = 0x01; *p++ = 0x00; *p++ = 0x5e; *p++ = 0x00; *p++ = 0x00; *p = 0x01; break; case MULTICAST_ROUTER: *p++ = 0x01; *p++ = 0x00; *p++ = 0x5e; *p++ = 0x00; *p++ = 0x00; *p = 0x02; break; @@ -137,7 +148,7 @@ } else { - switch (action) + switch (dest) { case MULTICAST_NODE: *p++ = 0x33; *p++ = 0x33; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p = 0x01; break; case MULTICAST_ROUTER: *p++ = 0x33; *p++ = 0x33; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p = 0x02; break;