aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorPaulo Alcantara <pcacjr@zytor.com>2012-05-04 02:17:46 -0300
committerPaulo Alcantara <pcacjr@zytor.com>2012-05-12 00:56:22 -0300
commit6aba981cd9310bae94587d3e51106261bf0e27b9 (patch)
tree46359ec76905f68643122469d255f62e345d6289 /com32
parent289cc36d32e57d28d5070e975101d37cd96580f2 (diff)
downloadsyslinux-6aba981cd9310bae94587d3e51106261bf0e27b9.tar.gz
syslinux-6aba981cd9310bae94587d3e51106261bf0e27b9.tar.xz
syslinux-6aba981cd9310bae94587d3e51106261bf0e27b9.zip
pxe: resolve names via DNS from protected-mode code
Syslinux used to call __intcall() for calling routines of the old COMBOOT API to resolve names via DNS (INT 22h, AX=0x0010) that seemed pointless, since INT 22h, AX=0x0010 does call the protected-mode function pm_pxe_resolv_dns() when calling INT 22h, AX=0x0010. So, for resolving names via DNS we must call pxe_dns_resolv() (a protected-mode function) instead for now. Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
Diffstat (limited to 'com32')
-rw-r--r--com32/include/syslinux/pxe.h4
-rw-r--r--com32/lib/Makefile1
-rw-r--r--com32/lib/syslinux/pxe_dns.c75
-rw-r--r--com32/libupload/upload_tftp.c2
-rw-r--r--com32/modules/host.c37
-rw-r--r--com32/samples/resolv.c21
6 files changed, 40 insertions, 100 deletions
diff --git a/com32/include/syslinux/pxe.h b/com32/include/syslinux/pxe.h
index 4e8a3369..156f4cf7 100644
--- a/com32/include/syslinux/pxe.h
+++ b/com32/include/syslinux/pxe.h
@@ -34,11 +34,11 @@
#ifndef _SYSLINUX_PXE_H
#define _SYSLINUX_PXE_H
+#include <pxe.h>
#include <syslinux/pxe_api.h>
/* SYSLINUX-defined PXE utility functions */
int pxe_get_cached_info(int level, void **buf, size_t *len);
-int pxe_get_nic_type(t_PXENV_UNDI_GET_NIC_TYPE * gnt);
-uint32_t pxe_dns(const char *hostname);
+int pxe_get_nic_type(t_PXENV_UNDI_GET_NIC_TYPE *gnt);
#endif /* _SYSLINUX_PXE_H */
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index bee1a023..7bb2d3ae 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -49,7 +49,6 @@ LIBSYSLINUX_OBJS = \
syslinux/features.o syslinux/config.o \
syslinux/dsinfo.o syslinux/version.o \
syslinux/pxe_get_cached.o syslinux/pxe_get_nic.o \
- syslinux/pxe_dns.o \
syslinux/video/fontquery.o syslinux/video/forcetext.o \
syslinux/video/reportmode.o
diff --git a/com32/lib/syslinux/pxe_dns.c b/com32/lib/syslinux/pxe_dns.c
deleted file mode 100644
index 6620396f..00000000
--- a/com32/lib/syslinux/pxe_dns.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * 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
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall
- * be included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * pxe_dns.c
- *
- * Resolve a hostname via DNS
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <com32.h>
-
-#include <syslinux/pxe.h>
-
-/* Returns the status code from PXE (0 on success),
- or -1 on invocation failure */
-uint32_t pxe_dns(const char *hostname)
-{
- com32sys_t regs;
- union {
- unsigned char b[4];
- uint32_t ip;
- } q;
- char *lm_hostname;
-
- /* 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;
-
- lm_hostname = lstrdup(hostname);
- if (!lm_hostname)
- return 0;
-
- memset(&regs, 0, sizeof regs);
- regs.eax.w[0] = 0x0010;
- regs.es = SEG(lm_hostname);
- /* regs.ebx.w[0] = OFFS(lm_hostname); */
-
- __intcall(0x22, &regs, &regs);
-
- lfree(lm_hostname);
-
- if (regs.eflags.l & EFLAGS_CF)
- return 0;
-
- return regs.eax.l;
-}
diff --git a/com32/libupload/upload_tftp.c b/com32/libupload/upload_tftp.c
index 5e73c1c5..10427ace 100644
--- a/com32/libupload/upload_tftp.c
+++ b/com32/libupload/upload_tftp.c
@@ -153,7 +153,7 @@ static int upload_tftp_write(struct upload_backend *be)
tftp.seq = 0;
if (be->argv[1]) {
- tftp.srv_ip = pxe_dns(be->argv[1]);
+ tftp.srv_ip = pxe_dns_resolv(be->argv[1]);
if (!tftp.srv_ip) {
// printf("\nUnable to resolve hostname: %s\n", be->argv[1]);
return -TFTP_ERR_UNABLE_TO_RESOLVE;
diff --git a/com32/modules/host.c b/com32/modules/host.c
index c8560c31..b43bd43b 100644
--- a/com32/modules/host.c
+++ b/com32/modules/host.c
@@ -1,13 +1,42 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Liu Aleaxander <Aleaxander@gmail.com>
+ * Copyright 2012 Paulo Alcantara <pcacjr@zytor.com>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
#include <stdio.h>
-#include <console.h>
#include <string.h>
-#include <netinet/in.h>
+#include <console.h>
#include <com32.h>
+
+#include <netinet/in.h>
#include <syslinux/pxe.h>
static inline uint32_t dns_resolve(const char *hostname)
{
- return pxe_dns(hostname);
+ return pxe_dns_resolv(hostname);
}
static inline void usage(const char *s)
@@ -24,7 +53,7 @@ int main(int argc, char *argv[])
if (argc < 2) {
usage(argv[0]);
- return 1;
+ exit(1);
}
for (i = 1; i < argc; i++) {
diff --git a/com32/samples/resolv.c b/com32/samples/resolv.c
index bd49d9f9..3446bd61 100644
--- a/com32/samples/resolv.c
+++ b/com32/samples/resolv.c
@@ -22,23 +22,11 @@
#include <stdlib.h>
#include <com32.h>
-uint32_t resolv(const char *name)
-{
- com32sys_t reg;
-
- strcpy((char *)__com32.cs_bounce, name);
-
- memset(&reg, 0, sizeof reg);
- reg.eax.w[0] = 0x0010;
- reg.ebx.w[0] = OFFS(__com32.cs_bounce);
- reg.es = SEG(__com32.cs_bounce);
+#include <syslinux/pxe.h>
- __intcall(0x22, &reg, &reg);
-
- if (reg.eflags.l & EFLAGS_CF)
- return 0;
- else
- return reg.eax.l;
+static inline uint32_t resolv(const char *name)
+{
+ return pxe_dns_resolv(name);
}
int main(int argc, char *argv[])
@@ -53,7 +41,6 @@ int main(int argc, char *argv[])
}
ip = resolv(argv[1]);
-
if (ip) {
printf("%s = %u.%u.%u.%u\n", argv[1],
(ip & 0xff), (ip >> 8) & 0xff,