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:
14:e75a59c1123d
Parent:
13:9cd54f7db57a
Child:
15:6ca6778168b1
--- a/udp/dns/dnshdr.cpp	Mon May 01 18:20:55 2017 +0000
+++ b/udp/dns/dnshdr.cpp	Fri May 05 17:44:16 2017 +0000
@@ -2,6 +2,11 @@
 #include     "dns.h"
 #include     "net.h"
 #include     "log.h"
+#include     "net.h"
+#include     "eth.h"
+#include     "ip4.h"
+#include     "ip6.h"
+#include     "udp.h"
 
 #define HEADER_LENGTH 12
 
@@ -75,8 +80,29 @@
 }
 void DnsHdrLog(char* title, int protocol)
 {
+    char text[100];
     LogTimeF("DNS %s\r\n", title);
-    char text[10];
+    if (EthProtocol == IPV6)
+    {
+        Ip6AddressToString(Ip6Src, sizeof(text), text);
+        LogF("  Src IP    %s\r\n", text);
+        Ip6AddressToString(Ip6Dst, sizeof(text), text);
+        LogF("  Dst IP    %s\r\n", text);
+    }
+    else if (EthProtocol == IPV4)
+    {
+        Ip4AddressToString(Ip4Src, sizeof(text), text);
+        LogF("  Src port  %s\r\n", text);
+        Ip4AddressToString(Ip4Dst, sizeof(text), text);
+        LogF("  Dst port  %s\r\n", text);
+    }
+    else
+    {
+        LogF("  Unknown eth protocol %04hX\r\n", EthProtocol);
+    }
+    LogF("  Source   %hu\r\n", UdpSrcPort);
+    LogF("  Dest     %hu\r\n", UdpDstPort);
+    
     DnsProtocolToString(protocol, sizeof(text), text);
     LogF("  Protocol %s\r\n", text);
     LogF("  Ident    %hd\r\n", DnsHdrId);
@@ -86,9 +112,6 @@
     else                        LogF("  Is not authoritative reply\r\n");
     if (DnsHdrIsRecursiveQuery) LogF("  Is recursive query\r\n");
     else                        LogF("  Is non recursive query\r\n");
-    LogF("  qdcount  %hu\r\n", DnsHdrQdcount);
-    LogF("  ancount  %hu\r\n", DnsHdrAncount);
-    LogF("  nscount  %hu\r\n", DnsHdrNscount);
-    LogF("  arcount  %hu\r\n", DnsHdrArcount);
+    LogF("  qd, an, ns, ar  %hu, %hu, %hu, %hu\r\n", DnsHdrQdcount, DnsHdrAncount, DnsHdrNscount, DnsHdrArcount);
 }