diff options
author | hpa <hpa> | 2004-12-28 23:49:43 +0000 |
---|---|---|
committer | hpa <hpa> | 2004-12-28 23:49:43 +0000 |
commit | 01b268cbf57515c37cad7dde05b6503e8d64bd5f (patch) | |
tree | b0f83e49823cea949bf8644071f0aca4dade270c /com32/samples | |
parent | b276b20eebea84bdf991d07da1bdff4c23b430c8 (diff) | |
download | syslinux-elf-01b268cbf57515c37cad7dde05b6503e8d64bd5f.tar.gz syslinux-elf-01b268cbf57515c37cad7dde05b6503e8d64bd5f.tar.xz syslinux-elf-01b268cbf57515c37cad7dde05b6503e8d64bd5f.zip |
Fix using the resolver function from the API (with DS != CS); addsyslinux-3.00-pre8
test/sample file to do that; fix bug in chain.c.
Diffstat (limited to 'com32/samples')
-rw-r--r-- | com32/samples/Makefile | 2 | ||||
-rw-r--r-- | com32/samples/resolv.c | 67 |
2 files changed, 68 insertions, 1 deletions
diff --git a/com32/samples/Makefile b/com32/samples/Makefile index 07d8156b..97985afa 100644 --- a/com32/samples/Makefile +++ b/com32/samples/Makefile @@ -39,7 +39,7 @@ LNXLIBS = ../libutil/libutil_lnx.a .SUFFIXES: .lss .c .o .elf .c32 .lnx -all: hello.c32 cat.c32 \ +all: hello.c32 cat.c32 resolv.c32 \ fancyhello.c32 fancyhello.lnx \ keytest.c32 keytest.lnx \ diff --git a/com32/samples/resolv.c b/com32/samples/resolv.c new file mode 100644 index 00000000..c82a974f --- /dev/null +++ b/com32/samples/resolv.c @@ -0,0 +1,67 @@ +#ident "$Id$" +/* ----------------------------------------------------------------------- * + * + * Copyright 2004 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * resolv.c + * + * Resolve an IP address + */ + +#include <string.h> +#include <stdio.h> +#include <console.h> +#include <stdlib.h> +#include <com32.h> + +uint32_t resolv(const char *name) +{ + com32sys_t reg; + + strcpy((char *)__com32.cs_bounce, name); + + memset(®, 0, sizeof reg); + reg.eax.w[0] = 0x0010; + reg.ebx.w[0] = OFFS(__com32.cs_bounce); + reg.es = SEG(__com32.cs_bounce); + + __intcall(0x22, ®, ®); + + if ( reg.eflags.l & EFLAGS_CF ) + return 0; + else + return reg.eax.l; +} + +int main(int argc, char *argv[]) +{ + uint32_t ip; + + openconsole(&dev_null_r, &dev_stdcon_w); + + if ( argc < 2 ) { + fputs("Usage: resolv hostname\n", stderr); + exit(1); + } + + ip = resolv(argv[1]); + + if ( ip ) { + printf("%s = %u.%u.%u.%u\n", argv[1], + (ip & 0xff), (ip >> 8) & 0xff, + (ip >> 16) & 0xff, (ip >> 24) & 0xff); + } else { + printf("%s not found\n", argv[1]); + } + + return 0; +} |