Andrew Boyson / net

Dependents:   oldheating gps motorhome heating

Files at this revision

API Documentation at this revision

Comitter:
andrewboyson
Date:
Thu Jan 21 14:56:55 2021 +0000
Parent:
189:e1c7990486c4
Child:
191:33392a61182e
Commit message:
Corrected a bug in DnsLabel whereby a ip4 encoded name was not recognised. This has been there a long time and came to light because MDNS was failing to return a name from an Ip4 address.

Changed in this revision

resolve/nrtest.c Show annotated file Show diff for this revision Revisions of this file
resolve/nrtest.h Show annotated file Show diff for this revision Revisions of this file
udp/dns/dnsname.c Show annotated file Show diff for this revision Revisions of this file
udp/dns/dnsserver.c Show annotated file Show diff for this revision Revisions of this file
--- a/resolve/nrtest.c	Thu Jan 21 13:34:33 2021 +0000
+++ b/resolve/nrtest.c	Thu Jan 21 14:56:55 2021 +0000
@@ -15,6 +15,14 @@
 {
     _doIt = true;
 }
+void NrTestAddress4FromName(void)
+{
+    NrMakeRequestForAddress4FromName(NrTest);
+}
+void NrTestAddress6FromName(void)
+{
+    NrMakeRequestForAddress6FromName(NrTest);
+}
 
 void NrTestMain(void)
 {
--- a/resolve/nrtest.h	Thu Jan 21 13:34:33 2021 +0000
+++ b/resolve/nrtest.h	Thu Jan 21 14:56:55 2021 +0000
@@ -1,5 +1,7 @@
 extern char NrTest[];
 
+extern void NrTestAddress4FromName(void);
+extern void NrTestAddress6FromName(void);
 extern void NrTestNameFromAddress(void);
 
 extern void NrTestMain(void);
\ No newline at end of file
--- a/udp/dns/dnsname.c	Thu Jan 21 13:34:33 2021 +0000
+++ b/udp/dns/dnsname.c	Thu Jan 21 14:56:55 2021 +0000
@@ -92,6 +92,7 @@
 }
 bool DnsNameCompareIp4(char *pStart, uint32_t ip)
 {
+    char ipBytes[4];
     int field = 0;
     int depth = 0;
     char* p = pStart;
@@ -133,8 +134,7 @@
                     byte += *p - '0';
                     p++;
                 }
-                if (byte != (ip & 0xFF)) return false;
-                ip >>= 8;
+                int ipByte = (ip >> 8 * (3 - field)) & 0xFF;
             }
             else if (field == 4)
             {
--- a/udp/dns/dnsserver.c	Thu Jan 21 13:34:33 2021 +0000
+++ b/udp/dns/dnsserver.c	Thu Jan 21 14:56:55 2021 +0000
@@ -70,7 +70,6 @@
         }
         bool nodeIsName  = DnsNameComparePtr(p, myFullName);
         bool nodeIsAddr4 = DnsNameCompareIp4(p, DhcpLocalIp);
-        if (nodeIsAddr4) LogTimeF("DnsServer received request for name from my Ip4 address\r\n");
         bool nodeIsLocl6 = DnsNameCompareIp6(p, SlaacLinkLocalIp);
         bool nodeIsUniq6 = DnsNameCompareIp6(p, SlaacUniqueLocalIp);
         bool nodeIsGlob6 = DnsNameCompareIp6(p, SlaacGlobalIp);