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:
15:6ca6778168b1
Parent:
14:e75a59c1123d
Child:
22:914b970356f0
--- a/udp/dns/dnsreply.cpp	Fri May 05 17:44:16 2017 +0000
+++ b/udp/dns/dnsreply.cpp	Tue May 09 15:39:03 2017 +0000
@@ -83,33 +83,18 @@
         case DNS_RECORD_A:
         case DNS_RECORD_AAAA:
         case DNS_RECORD_PTR:
+        case DNS_RECORD_SRV:
+        case DNS_RECORD_TXT:
             break;
         default:    
             LogTimeF("DnsReply readAnswer unrecognised record type %d\r\n", recordType);
-            return;    }
+            return;
+    }
 
     DnsNameDecode   (recordNameOffset, sizeof(DnsReplyRecordName), DnsReplyRecordName);
     DnsNameDecodeIp4(recordNameOffset, &DnsReplyRecordNameAsIp4);
     DnsNameDecodeIp6(recordNameOffset,  DnsReplyRecordNameAsIp6);
-    if (DEBUG)
-    {
-        LogF("  record name as string %s\r\n",  DnsReplyRecordName);
-        char text[100];
-        if (DnsReplyRecordNameAsIp4)
-        {
-            Ip4AddressToString(DnsReplyRecordNameAsIp4, sizeof(text), text);
-            LogF("  record name as ip4  %s\r\n",  text);
-        }
-        if (DnsReplyRecordNameAsIp6[0])
-        {
-            Ip6AddressToString(DnsReplyRecordNameAsIp6, sizeof(text), text);
-            LogF("  record name as ip6  %s\r\n",  text);
-        }
-        DnsRecordTypeToString(recordType, sizeof(text), text);
-        LogF("  record type %s\r\n", text);
-        LogF("  record data length %d bytes\r\n", recordDataLength);
-    }
-    
+
     switch (recordType)
     {
         case DNS_RECORD_A:
@@ -137,21 +122,38 @@
             DnsNameDecode(DnsNameIndexFromPointer(pRecordData), sizeof(DnsReplyName), DnsReplyName);
             break;
     }
+
     if (DEBUG)
     {
+        LogF("  answer: %s",  DnsReplyRecordName);
         char text[100];
+        if (DnsReplyRecordNameAsIp4)
+        {
+            Ip4AddressToString(DnsReplyRecordNameAsIp4, sizeof(text), text);
+            LogF(" (%s)",  text);
+        }
+        if (DnsReplyRecordNameAsIp6[0])
+        {
+            Ip6AddressToString(DnsReplyRecordNameAsIp6, sizeof(text), text);
+            LogF(" (%s)",  text);
+        }
+        LogF(" == ");
         switch (recordType)
         {
             case DNS_RECORD_A:
                 Ip4AddressToString(DnsReplyIp4, sizeof(text), text);
-                LogF("  ip4      %s\r\n",  text);
+                LogF("%s\r\n",  text);
                 break;
             case DNS_RECORD_AAAA:
                 Ip6AddressToString(DnsReplyIp6, sizeof(text), text);
-                LogF("  ip6      %s\r\n",  text);
+                LogF("%s\r\n",  text);
                 break;
             case DNS_RECORD_PTR:
-                LogF("  ptr      %s\r\n",  DnsReplyName);
+                LogF("%s\r\n",  DnsReplyName);
+                break;
+            default:
+                DnsRecordTypeToString(recordType, sizeof(text), text);
+                LogF("%d bytes of %s\r\n", recordDataLength, text);
                 break;
         }
     }