[syslinux:elflink] host.c32: do not use INT 22h, AX= 0x0010 to resolve DNS

syslinux-bot for Paulo Alcantara pcacjr at zytor.com
Wed May 16 14:21:06 PDT 2012


Commit-ID:  92bfa616f96e9725b34f319db9d8736161e157a5
Gitweb:     http://www.syslinux.org/commit/92bfa616f96e9725b34f319db9d8736161e157a5
Author:     Paulo Alcantara <pcacjr at zytor.com>
AuthorDate: Mon, 30 Apr 2012 01:49:16 -0300
Committer:  Paulo Alcantara <pcacjr at zytor.com>
CommitDate: Sat, 12 May 2012 00:56:22 -0300

host.c32: do not use INT 22h, AX=0x0010 to resolve DNS

Use pxe_dns() function (assigned in syslinux/pxe.h) instead for
resolving DNS.

Signed-off-by: Paulo Alcantara <pcacjr at zytor.com>

---
 com32/modules/host.c |   43 ++++++++++++++++++++++---------------------
 1 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/com32/modules/host.c b/com32/modules/host.c
index c9cea97..c8560c3 100644
--- a/com32/modules/host.c
+++ b/com32/modules/host.c
@@ -3,37 +3,38 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <com32.h>
+#include <syslinux/pxe.h>
 
-static struct in_addr dnsresolve(const char *hostname)
+static inline uint32_t dns_resolve(const char *hostname)
 {
-    com32sys_t regs;
-    struct in_addr addr;
-
-    strcpy(__com32.cs_bounce, hostname);
-    
-    regs.eax.w[0] = 0x0010;
-    regs.es       = SEG(__com32.cs_bounce);
-    regs.ebx.w[0] = OFFS(__com32.cs_bounce);
-    __intcall(0x22, &regs, &regs);
+    return pxe_dns(hostname);
+}
 
-    addr.s_addr = regs.eax.l;
-    return addr;
+static inline void usage(const char *s)
+{
+    fprintf(stderr, "Usage: %s hostname [, hostname_1, hostname_2, ...]\n", s);
 }
 
 int main(int argc, char *argv[])
 {
     int i;
-    struct in_addr addr;
+    uint32_t ip;
 
-    for (i = 1; i < argc; i++) {
-	addr = dnsresolve(argv[i]);
+    openconsole(&dev_null_r, &dev_stdcon_w);
 
-	printf("%-39s %08X %d.%d.%d.%d\n",
-	       argv[i], ntohl(addr.s_addr),
-	       ((uint8_t *)&addr.s_addr)[0], 
-	       ((uint8_t *)&addr.s_addr)[1], 
-	       ((uint8_t *)&addr.s_addr)[2], 
-	       ((uint8_t *)&addr.s_addr)[3]);
+    if (argc < 2) {
+        usage(argv[0]);
+        return 1;
+    }
+
+    for (i = 1; i < argc; i++) {
+        ip = dns_resolve(argv[i]);
+        if (!ip) {
+            printf("%s not found.\n", argv[i]);
+        } else {
+            printf("%-39s %08X %u.%u.%u.%u\n", argv[i], ntohl(ip), ip & 0xFF,
+                   (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24) & 0xFF);
+        }
     }
 
     return 0;


More information about the Syslinux-commits mailing list