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:
35:93c39d260a83
Parent:
32:679654f2d023
Child:
37:793b39683406
diff -r e3a7bff69bfc -r 93c39d260a83 udp/dns/dnsreply.cpp
--- a/udp/dns/dnsreply.cpp	Fri Sep 01 15:06:59 2017 +0000
+++ b/udp/dns/dnsreply.cpp	Fri Sep 22 13:55:56 2017 +0000
@@ -4,7 +4,7 @@
 #include   "ip4.h"
 #include   "ip6.h"
 #include    "ar.h"
-#include   "dnscache.h"
+#include    "nr.h"
 #include   "dns.h"
 #include   "dnshdr.h"
 #include   "dnsname.h"
@@ -116,9 +116,9 @@
             memcpy(DnsReplyIp6, pRecordData, 16);
             break;
         case DNS_RECORD_PTR:
-            if (recordDataLength > 63)
+            if (recordDataLength > DNS_MAX_LABEL_LENGTH)
             {
-                LogTimeF("DnsReply PTR type length of %d\r\n", recordDataLength);
+                LogTimeF("DnsReply PTR type length %d is greater than max DNS label length of %d\r\n", recordDataLength, DNS_MAX_LABEL_LENGTH);
                 return;
             }
             DnsNameDecode(DnsNameIndexFromPointer(pRecordData), sizeof(DnsReplyName), DnsReplyName);
@@ -161,23 +161,16 @@
     }
 }
 
-static void sendToAr(int dnsProtocol)
-{
-    if (DnsReplyIp4                && DnsReplyRecordName[0]) ArAddName4(DnsReplyIp4,             DnsReplyRecordName, dnsProtocol);
-    if (DnsReplyIp6[0]             && DnsReplyRecordName[0]) ArAddName6(DnsReplyIp6,             DnsReplyRecordName, dnsProtocol);
-    if (DnsReplyRecordNameAsIp4    && DnsReplyName[0]      ) ArAddName4(DnsReplyRecordNameAsIp4, DnsReplyName,       dnsProtocol);
-    if (DnsReplyRecordNameAsIp6[0] && DnsReplyName[0]      ) ArAddName6(DnsReplyRecordNameAsIp6, DnsReplyName,       dnsProtocol);
-}
 static void sendToDnsCache(int dnsProtocol)
 {
     char strippedName[100];
     if (DnsReplyRecordName[0]) DnsStripNameFromFullName(dnsProtocol, DnsReplyRecordName, sizeof(strippedName), strippedName);
     if (DnsReplyName[0]      ) DnsStripNameFromFullName(dnsProtocol, DnsReplyName      , sizeof(strippedName), strippedName);
     
-    if (DnsReplyIp4                && DnsReplyRecordName[0]) DnsCacheAddIp4Record(DnsReplyIp4,             strippedName, dnsProtocol);
-    if (DnsReplyIp6[0]             && DnsReplyRecordName[0]) DnsCacheAddIp6Record(DnsReplyIp6,             strippedName, dnsProtocol);
-    if (DnsReplyRecordNameAsIp4    && DnsReplyName[0]      ) DnsCacheAddIp4Record(DnsReplyRecordNameAsIp4, strippedName, dnsProtocol);
-    if (DnsReplyRecordNameAsIp6[0] && DnsReplyName[0]      ) DnsCacheAddIp6Record(DnsReplyRecordNameAsIp6, strippedName, dnsProtocol);
+    if (DnsReplyIp4                && DnsReplyRecordName[0]) NrAddIp4Record(DnsReplyIp4,             strippedName, dnsProtocol);
+    if (DnsReplyIp6[0]             && DnsReplyRecordName[0]) NrAddIp6Record(DnsReplyIp6,             strippedName, dnsProtocol);
+    if (DnsReplyRecordNameAsIp4    && DnsReplyName[0]      ) NrAddIp4Record(DnsReplyRecordNameAsIp4, strippedName, dnsProtocol);
+    if (DnsReplyRecordNameAsIp6[0] && DnsReplyName[0]      ) NrAddIp6Record(DnsReplyRecordNameAsIp6, strippedName, dnsProtocol);
 }
 int DnsReplyHandle(int dnsProtocol, int *pSize)
 {        
@@ -194,7 +187,6 @@
     {
         if (scanAnswer()) return DO_NOTHING;
         readAnswer();
-        sendToAr(dnsProtocol);
         sendToDnsCache(dnsProtocol);
     }