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
Diff: udp/dns/dnsquery.c
- Revision:
- 176:7eb916c22084
- Parent:
- 173:9bc30cd82a76
- Child:
- 187:122fc1996c86
diff -r 2d7aa004d881 -r 7eb916c22084 udp/dns/dnsquery.c --- a/udp/dns/dnsquery.c Thu Dec 24 19:17:06 2020 +0000 +++ b/udp/dns/dnsquery.c Sat Dec 26 17:07:02 2020 +0000 @@ -65,6 +65,11 @@ } void DnsQueryIp4FromName(char * name, int dnsProtocol, int ipProtocol) { + if (!name[0]) + { + LogTime("DnsQueryIp4FromName called with no name\r\n"); + return; + } DnsLabelMakeFullNameFromName(dnsProtocol, name, sizeof(DnsQueryName), DnsQueryName); DnsQueryIp4 = 0; DnsQueryIp6[0] = 0; @@ -76,6 +81,11 @@ } void DnsQueryIp6FromName(char * name, int dnsProtocol, int ipProtocol) { + if (!name[0]) + { + LogTime("DnsQueryIp6FromName called with no name\r\n"); + return; + } DnsLabelMakeFullNameFromName(dnsProtocol, name, sizeof(DnsQueryName), DnsQueryName); DnsQueryIp4 = 0; DnsQueryIp6[0] = 0; @@ -87,6 +97,11 @@ } void DnsQueryNameFromIp4(uint32_t ip, int dnsProtocol, int ipProtocol) { + if (!ip) + { + LogTime("DnsQueryNameFromIp4 called with no ip\r\n"); + return; + } DnsQueryName[0] = 0; DnsQueryIp4 = ip; DnsQueryIp6[0] = 0; @@ -98,6 +113,11 @@ } void DnsQueryNameFromIp6(char* ip, int dnsProtocol, int ipProtocol) { + if (!ip[0]) + { + LogTime("DnsQueryNameFromIp6 called with no ip\r\n"); + return; + } DnsQueryName[0] = 0; DnsQueryIp4 = 0; Ip6AddrCopy(DnsQueryIp6, ip); @@ -157,9 +177,10 @@ DnsHdrWrite(); char* p = DnsHdrData; - if (DnsQueryIp4 ) DnsNameEncodeIp4(DnsQueryIp4, &p); - else if (DnsQueryIp6[0]) DnsNameEncodeIp6(DnsQueryIp6, &p); - else DnsNameEncodePtr(DnsQueryName, &p); + if (DnsQueryIp4 ) DnsNameEncodeIp4(DnsQueryIp4, &p); + else if (DnsQueryIp6[0] ) DnsNameEncodeIp6(DnsQueryIp6, &p); + else if (DnsQueryName[0]) DnsNameEncodePtr(DnsQueryName, &p); + else return DO_NOTHING; *p++ = 0; *p++ = _RecordType;