1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <console.h>
5 #include <netinet/in.h>
6 #include <com32.h>
7 #include <syslinux/pxe.h>
8 
9 static inline uint32_t dns_resolve(const char *hostname)
10 {
11     return pxe_dns(hostname);
12 }
13 
14 static inline void usage(const char *s)
15 {
16     fprintf(stderr, "Usage: %s hostname [, hostname_1, hostname_2, ...]\n", s);
17 }
18 
19 int main(int argc, char *argv[])
20 {
21     int i;
22     uint32_t ip;
23 
24     openconsole(&dev_null_r, &dev_stdcon_w);
25 
26     if (argc < 2) {
27         usage(argv[0]);
28         return 1;
29     }
30 
31     for (i = 1; i < argc; i++) {
32         ip = dns_resolve(argv[i]);
33         if (!ip) {
34             printf("%s not found.\n", argv[i]);
35         } else {
36             printf("%-39s %08X %u.%u.%u.%u\n", argv[i], ntohl(ip), ip & 0xFF,
37                    (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24) & 0xFF);
38         }
39     }
40 
41     return 0;
42 }
43