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:
59:e0e556c8bd46
Parent:
49:1a6336f2b3f9
--- a/udp/dhcp.cpp	Thu Dec 07 20:44:32 2017 +0000
+++ b/udp/dhcp.cpp	Thu Dec 14 20:55:40 2017 +0000
@@ -226,38 +226,38 @@
     delayTime = 0;
     return HEADER_LENGTH + p - pOptions;
 }
-int DhcpHandleResponse(void (*traceback)(void), int* pSize, void* pPacket)
+int DhcpHandleResponse(void (*traceback)(void), int sizeRx, void* pPacketRx, int* pSizeTx, void* pPacketTx)
 {
-    struct header* pHeader = (header*)pPacket;
+    struct header* pHeaderRx = (header*)pPacketRx;
 
-    uint8_t  op      = pHeader->op;
-    uint8_t  htype   = pHeader->htype;
-    uint8_t  hlen    = pHeader->hlen;
+    uint8_t  op      = pHeaderRx->op;
+    uint8_t  htype   = pHeaderRx->htype;
+    uint8_t  hlen    = pHeaderRx->hlen;
     
-    uint32_t xid     = pHeader->xid;    //Randomly chosen transaction id used to associate messages to responses
+    uint32_t xid     = pHeaderRx->xid;    //Randomly chosen transaction id used to associate messages to responses
     
-    uint16_t secs    = NetToHost16(pHeader->secs);
-    uint16_t flags   = NetToHost16(pHeader->flags);
+    uint16_t secs    = NetToHost16(pHeaderRx->secs);
+    uint16_t flags   = NetToHost16(pHeaderRx->flags);
     
-    uint32_t yiaddr  = pHeader->yiaddr;
-    uint32_t siaddr  = pHeader->siaddr;
-    uint32_t cookie  = NetToHost32(pHeader->cookie);
+    uint32_t yiaddr  = pHeaderRx->yiaddr;
+    uint32_t siaddr  = pHeaderRx->siaddr;
+    uint32_t cookie  = NetToHost32(pHeaderRx->cookie);
         
-    if (op     != REPLY)                      return DO_NOTHING;
-    if (htype  != ETHERNET)                   return DO_NOTHING;
-    if (hlen   != 6)                          return DO_NOTHING;
-    if (memcmp(pHeader->chaddr, MacLocal, 6)) return DO_NOTHING;
-    if (xid    != ID)                         return DO_NOTHING;
-    if (cookie != COOKIE)                     return DO_NOTHING;
+    if (op     != REPLY)                        return DO_NOTHING;
+    if (htype  != ETHERNET)                     return DO_NOTHING;
+    if (hlen   != 6)                            return DO_NOTHING;
+    if (memcmp(pHeaderRx->chaddr, MacLocal, 6)) return DO_NOTHING;
+    if (xid    != ID)                           return DO_NOTHING;
+    if (cookie != COOKIE)                       return DO_NOTHING;
     
-    char* pOptions = (char*)pPacket + HEADER_LENGTH;
-    readOptions(*pSize - HEADER_LENGTH, pOptions);
+    char* pOptions = (char*)pPacketRx + HEADER_LENGTH;
+    readOptions(sizeRx - HEADER_LENGTH, pOptions);
     
     switch (dhcpMessageType)
     {
         case DHCPOFFER:
             if (DhcpTrace) { LogTime("DHCP <- offer ip "); Ip4AddressLog(yiaddr); Log("\r\n"); }
-            *pSize =sendRequest(pPacket, DHCPREQUEST, siaddr, yiaddr);
+            *pSizeTx = sendRequest(pPacketTx, DHCPREQUEST, siaddr, yiaddr);
             return BROADCAST;
         case DHCPACK:
             if (DhcpTrace) { LogTime("DHCP <- ack ip ");   Ip4AddressLog(yiaddr); Log("\r\n"); }