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:
195:bd5b123143ca
Parent:
172:9bc3c7b2cca1
--- a/eth/eth.c	Thu Mar 04 12:08:14 2021 +0000
+++ b/eth/eth.c	Sun Apr 18 19:04:48 2021 +0000
@@ -13,6 +13,7 @@
 #define MTU 1500
 
 uint16_t EthProtocol; //Set when receiving or sending packets so that higher levels can read the protocol in use
+char*    EthMacRemote; //Set when receiving packets so that higher levels can read the protocol in use
 
 //header variables
 static char*    hdrDstPtr(char* pPacket) { return pPacket +  0; }
@@ -83,12 +84,12 @@
     NetTraceHostCheckMac(hdrSrcPtr(pPacketRx));
 
     int   action = DO_NOTHING;
-    char* macRemote = hdrSrcPtr(pPacketRx);
+    EthMacRemote = hdrSrcPtr(pPacketRx);
     switch (EthProtocol)
     {
-        case ETH_ARP:  action = ArpHandleReceivedPacket(trace, pDataRx, dataLengthRx, pDataTx, &dataLengthTx);            break;
-        case ETH_IPV4: action = Ip4HandleReceivedPacket(trace, pDataRx, dataLengthRx, pDataTx, &dataLengthTx, macRemote); break;
-        case ETH_IPV6: action = Ip6HandleReceivedPacket(trace, pDataRx, dataLengthRx, pDataTx, &dataLengthTx, macRemote); break;
+        case ETH_ARP:  action = ArpHandleReceivedPacket(trace, pDataRx, dataLengthRx, pDataTx, &dataLengthTx);               break;
+        case ETH_IPV4: action = Ip4HandleReceivedPacket(trace, pDataRx, dataLengthRx, pDataTx, &dataLengthTx, EthMacRemote); break;
+        case ETH_IPV6: action = Ip6HandleReceivedPacket(trace, pDataRx, dataLengthRx, pDataTx, &dataLengthTx, EthMacRemote); break;
         case 0x6970: break; //Drop Sonos group membership packet
         case 0x7374: break; //Drop Sky Q packet
         case 0x7475: break; //Drop Sky Q packet
@@ -105,9 +106,9 @@
         return DO_NOTHING;
     }
         
-    MacMakeFromDest(ActionGetDestPart(action), EthProtocol, macRemote);
+    MacMakeFromDest(ActionGetDestPart(action), EthProtocol, EthMacRemote);
     MacCopy(hdrSrcPtr(pPacketTx), MacLocal);
-    MacCopy(hdrDstPtr(pPacketTx), macRemote);
+    MacCopy(hdrDstPtr(pPacketTx), EthMacRemote);
     hdrTypSet(pPacketTx, EthProtocol);
     
     *pSizeTx = HEADER_LENGTH + dataLengthTx;