aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--com32/include/syslinux/pxe.h4
-rw-r--r--com32/lib/Makefile1
-rw-r--r--com32/libupload/upload_tftp.c2
-rw-r--r--com32/modules/host.c37
-rw-r--r--com32/samples/resolv.c21
-rw-r--r--core/include/pxe.h (renamed from com32/lib/syslinux/pxe_dns.c)50
-rw-r--r--mk/com32.mk3
-rw-r--r--mk/elf.mk3
8 files changed, 53 insertions, 68 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/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,
diff --git a/com32/lib/syslinux/pxe_dns.c b/core/include/pxe.h
index 6620396f..86d6cfc4 100644
--- a/com32/lib/syslinux/pxe_dns.c
+++ b/core/include/pxe.h
@@ -1,6 +1,7 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2010 Intel Corporation; author: H. Peter Anvin
+ * 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
@@ -25,51 +26,18 @@
*
* ----------------------------------------------------------------------- */
-/*
- * pxe_dns.c
- *
- * Resolve a hostname via DNS
- */
+#ifndef PXE_H_
+#define PXE_H_
#include <stdio.h>
-#include <stdlib.h>
#include <stdint.h>
-#include <string.h>
-#include <com32.h>
-#include <syslinux/pxe.h>
+extern uint32_t dns_resolv(const char *);
-/* Returns the status code from PXE (0 on success),
- or -1 on invocation failure */
-uint32_t pxe_dns(const char *hostname)
+/* Resolve a hostname via DNS */
+static inline uint32_t pxe_dns_resolv(const char *name)
{
- 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;
+ return dns_resolv(name);
}
+
+#endif /* PXE_H_ */
diff --git a/mk/com32.mk b/mk/com32.mk
index 262d2a6c..6e7e9a68 100644
--- a/mk/com32.mk
+++ b/mk/com32.mk
@@ -48,7 +48,8 @@ endif
CFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
-fomit-frame-pointer -D__COM32__ \
-nostdinc -iwithprefix include \
- -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
+ -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE) \
+ -I../../core/include
SFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
-fomit-frame-pointer -D__COM32__ \
-nostdinc -iwithprefix include \
diff --git a/mk/elf.mk b/mk/elf.mk
index ca061152..c5d50551 100644
--- a/mk/elf.mk
+++ b/mk/elf.mk
@@ -44,7 +44,8 @@ endif
CFLAGS = $(GCCOPT) -W -Wall -march=i386 \
-fomit-frame-pointer -D__COM32__ -DDYNAMIC_MODULE \
-nostdinc -iwithprefix include \
- -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
+ -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE) \
+ -I../../core/include
SFLAGS = $(GCCOPT) -D__COM32__ -march=i386
LDFLAGS = -m elf_i386 -shared --hash-style=gnu -T $(com32)/lib/elf32.ld