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:
13:9cd54f7db57a
Parent:
10:f0854784e960
Child:
14:e75a59c1123d
--- a/udp/udp.cpp	Thu Apr 20 13:50:30 2017 +0000
+++ b/udp/udp.cpp	Mon May 01 18:20:55 2017 +0000
@@ -9,6 +9,7 @@
 #include   "ip6.h"
 #include "slaac.h"
 #include   "ndp.h"
+#include    "io.h"
 
 #define UNKNOWN false
 
@@ -30,11 +31,11 @@
     switch (dstPort)
     {
         //Handle these
-        case DHCP_CLIENT_PORT:          return DhcpHandleResponse(pDataLength, pData);  //68
-        case NTP_SERVER_PORT:           return  NtpHandleRequest (pDataLength, pData);  //123
-        case DNS_CLIENT_PORT:           return  DnsHandleResponse(pDataLength, pData);  //53053
-        case DNS_MULTICAST_SERVER_PORT: return  DnsHandleRequest (DNS_TYPE_MDNS,  pDataLength, pData);  //5353
-        case DNS_LLMNR_SERVER_PORT:     return  DnsHandleRequest (DNS_TYPE_LLMNR, pDataLength, pData);  //5355
+        case DHCP_CLIENT_PORT:          return DhcpHandleResponse      (                    pDataLength, pData);  //   68
+        case NTP_SERVER_PORT:           return  NtpHandleRequest       (                    pDataLength, pData);  //  123
+        case DNS_CLIENT_PORT:           return  DnsHandlePacketReceived(DNS_PROTOCOL_UDNS,  pDataLength, pData);  //53053
+        case DNS_MULTICAST_SERVER_PORT: return  DnsHandlePacketReceived(DNS_PROTOCOL_MDNS,  pDataLength, pData);  // 5353
+        case DNS_LLMNR_SERVER_PORT:     return  DnsHandlePacketReceived(DNS_PROTOCOL_LLMNR, pDataLength, pData);  // 5355
         
         //Quietly drop these
         case DHCP_SERVER_PORT:                                                          //67
@@ -83,15 +84,14 @@
     
     if (!action) //DNS is agnostic
     {
-        action = DnsPollForRequestToSend(pData, pDataLength);
+        action = DnsPollForPacketToSend(pData, pDataLength);
         if (action)
         {
-            srcPort = DNS_CLIENT_PORT;                                            //53053
             switch (action)
             {
-                case   UNICAST_DNS:   dstPort = DNS_UNICAST_SERVER_PORT;   break; //53
-                case MULTICAST_MDNS:  dstPort = DNS_MULTICAST_SERVER_PORT; break; //5353
-                case MULTICAST_LLMNR: dstPort = DNS_LLMNR_SERVER_PORT;     break; //5355
+                case   UNICAST_DNS:    srcPort = DNS_CLIENT_PORT;           dstPort = DNS_UNICAST_SERVER_PORT;   break; //53053,   53
+                case MULTICAST_MDNS:   srcPort = DNS_MULTICAST_SERVER_PORT; dstPort = DNS_MULTICAST_SERVER_PORT; break; // 5353, 5353
+                case MULTICAST_LLMNR:  srcPort = DNS_CLIENT_PORT;           dstPort = DNS_LLMNR_SERVER_PORT;     break; //53053, 5355
                 
                 //Report anything else
                 default: