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:
33:714a0345e59b
diff -r e75a59c1123d -r 6ca6778168b1 udp/dns/dnshdr.cpp
--- a/udp/dns/dnshdr.cpp	Fri May 05 17:44:16 2017 +0000
+++ b/udp/dns/dnshdr.cpp	Tue May 09 15:39:03 2017 +0000
@@ -81,37 +81,38 @@
 void DnsHdrLog(char* title, int protocol)
 {
     char text[100];
-    LogTimeF("DNS %s\r\n", title);
+    DnsProtocolToString(protocol, sizeof(text), text);
+    LogTimeF("%s %s\r\n", text, title);
     if (EthProtocol == IPV6)
     {
         Ip6AddressToString(Ip6Src, sizeof(text), text);
-        LogF("  Src IP    %s\r\n", text);
+        LogF("  IP: src %s;", text);
         Ip6AddressToString(Ip6Dst, sizeof(text), text);
-        LogF("  Dst IP    %s\r\n", text);
+        LogF(" dst %s\r\n", text);
     }
     else if (EthProtocol == IPV4)
     {
         Ip4AddressToString(Ip4Src, sizeof(text), text);
-        LogF("  Src port  %s\r\n", text);
+        LogF("  IP: src %s;", text);
         Ip4AddressToString(Ip4Dst, sizeof(text), text);
-        LogF("  Dst port  %s\r\n", text);
+        LogF(" dst %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("  Port: src %5hu; dst %5hu\r\n", UdpSrcPort, UdpDstPort);
     LogF("  Ident    %hd\r\n", DnsHdrId);
-    if (DnsHdrIsReply)          LogF("  Is reply\r\n");
-    else                        LogF("  Is request\r\n");
-    if (DnsHdrIsAuthoritative)  LogF("  Is authoritative reply\r\n");
-    else                        LogF("  Is not authoritative reply\r\n");
-    if (DnsHdrIsRecursiveQuery) LogF("  Is recursive query\r\n");
-    else                        LogF("  Is non recursive query\r\n");
+    if (DnsHdrIsReply)
+    {
+        if (DnsHdrIsAuthoritative)  LogF("  Authoritative reply\r\n");
+        else                        LogF("  Non authoritative reply\r\n");
+    }
+    else
+    {
+        if (DnsHdrIsRecursiveQuery) LogF("  Recursive query\r\n");
+        else                        LogF("  Non recursive query\r\n");
+    }
     LogF("  qd, an, ns, ar  %hu, %hu, %hu, %hu\r\n", DnsHdrQdcount, DnsHdrAncount, DnsHdrNscount, DnsHdrArcount);
 }