[syslinux:master] com32: add library function for DNS lookup
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Sat Feb 6 17:48:12 PST 2010
Commit-ID: 7d31294fd5966ba2a8d6e47f663a13d52eae9046
Gitweb: http://syslinux.zytor.com/commit/7d31294fd5966ba2a8d6e47f663a13d52eae9046
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sat, 6 Feb 2010 16:31:26 -0800
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Sat, 6 Feb 2010 16:31:26 -0800
com32: add library function for DNS lookup
Add a library function for DNS lookup
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
com32/lib/Makefile | 1 +
com32/lib/syslinux/{pxe_get_nic.c => pxe_dns.c} | 31 ++++++++++++++--------
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index ff5887b..9c0a113 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -108,6 +108,7 @@ LIBOBJS = \
syslinux/initramfs_archive.o \
\
syslinux/pxe_get_cached.o syslinux/pxe_get_nic.o \
+ syslinux/pxe_dns.o \
\
syslinux/adv.o syslinux/advwrite.o syslinux/getadv.o \
syslinux/setadv.o \
diff --git a/com32/lib/syslinux/pxe_get_nic.c b/com32/lib/syslinux/pxe_dns.c
similarity index 76%
copy from com32/lib/syslinux/pxe_get_nic.c
copy to com32/lib/syslinux/pxe_dns.c
index 704a0d7..9ab9513 100644
--- a/com32/lib/syslinux/pxe_get_nic.c
+++ b/com32/lib/syslinux/pxe_dns.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
+ * Copyright 2010 Intel Corporation; author: H. Peter Anvin
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -26,11 +26,12 @@
* ----------------------------------------------------------------------- */
/*
- * pxe_get_cached.c
+ * pxe_dns.c
*
- * PXE call "get cached info"
+ * Resolve a hostname via DNS
*/
+#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
@@ -40,22 +41,30 @@
/* Returns the status code from PXE (0 on success),
or -1 on invocation failure */
-int pxe_get_nic_type(t_PXENV_UNDI_GET_NIC_TYPE * gnt)
+uint32_t pxe_dns(const char *hostname)
{
com32sys_t regs;
+ union {
+ unsigned char b[4];
+ uint32_t ip;
+ } q;
+
+ /* Is this a dot-quad? */
+ if (sscanf(hostname, "%hhu.%hhu.%hhu.%hhu",
+ &q.b[0], &q.b[1], &q.b[2], &q.b[3]) == 4)
+ return q.ip;
memset(®s, 0, sizeof regs);
- regs.eax.w[0] = 0x0009;
- regs.ebx.w[0] = PXENV_UNDI_GET_NIC_TYPE;
+ regs.eax.w[0] = 0x0010;
regs.es = SEG(__com32.cs_bounce);
- regs.edi.w[0] = OFFS(__com32.cs_bounce);
+ regs.ebx.w[0] = OFFS(__com32.cs_bounce);
- __intcall(0x22, ®s, ®s);
+ strcpy((char *)__com32.cs_bounce, hostname);
- memcpy(gnt, __com32.cs_bounce, sizeof(t_PXENV_UNDI_GET_NIC_TYPE));
+ __intcall(0x22, ®s, ®s);
if (regs.eflags.l & EFLAGS_CF)
- return -1;
+ return 0;
- return gnt->Status;
+ return regs.eax.l;
}
More information about the Syslinux-commits
mailing list