aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-07-19 10:44:48 +0100
committerMatt Fleming <matt.fleming@intel.com>2013-07-19 10:45:14 +0100
commit5e589953fdb4afaf3ea2a566bc8d635853ab984f (patch)
treefd9e1b91455f0ecd8321b447a1384a53366c0c2a
parent65b7d4306aac6b81743df93fe23f6e24d64025f3 (diff)
parent82d3dcee9ed95423a5bc7dc8159a576e9fc04431 (diff)
downloadsyslinux-5e589953fdb4afaf3ea2a566bc8d635853ab984f.tar.gz
Merge branch 'pxe-dns-dotquad-for-mfleming' of git://github.com/geneC/syslinux into firmwaresyslinux-6.02-pre7
Pull PXE legacynet DNS dotquad fix from Gene Cumm, * 'pxe-dns-dotquad-for-mfleming' of git://github.com/geneC/syslinux: core/legacynet: Enable dot quad resolution
-rw-r--r--core/legacynet/dnsresolv.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/core/legacynet/dnsresolv.c b/core/legacynet/dnsresolv.c
index fab36aef..fdbe795c 100644
--- a/core/legacynet/dnsresolv.c
+++ b/core/legacynet/dnsresolv.c
@@ -170,6 +170,37 @@ extern uint16_t get_port(void);
extern void free_port(uint16_t port);
/*
+ * parse the ip_str and return the ip address with *res.
+ * return true if the whole string was consumed and the result
+ * was valid.
+ *
+ */
+static bool parse_dotquad(const char *ip_str, uint32_t *res)
+{
+ const char *p = ip_str;
+ uint8_t part = 0;
+ uint32_t ip = 0;
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ while (is_digit(*p)) {
+ part = part * 10 + *p - '0';
+ p++;
+ }
+ if (i != 3 && *p != '.')
+ return false;
+
+ ip = (ip << 8) | part;
+ part = 0;
+ p++;
+ }
+ p--;
+
+ *res = htonl(ip);
+ return *p == '\0';
+}
+
+/*
* Actual resolver function
* Points to a null-terminated or :-terminated string in _name_
* and returns the ip addr in _ip_ if it exists and can be found.
@@ -209,6 +240,10 @@ __export uint32_t dns_resolv(const char *name)
if (!name || !*name)
return 0;
+ /* If it is a valid dot quad, just return that value */
+ if (parse_dotquad(name, &result))
+ return result;
+
/* Make sure we have at least one valid DNS server */
if (!dns_server[0])
return 0;