5 #include <gpxe/process.h>
6 #include <gpxe/resolv.h>
8 FILE_LICENCE ( GPL2_OR_LATER );
10 static int comboot_resolv_rc;
11 static struct in_addr comboot_resolv_addr;
13 static void comboot_resolv_done ( struct resolv_interface *resolv,
14 struct sockaddr *sa, int rc ) {
15 struct sockaddr_in *sin;
17 resolv_unplug ( resolv );
20 comboot_resolv_rc = rc;
24 if ( sa->sa_family != AF_INET ) {
25 comboot_resolv_rc = -EAFNOSUPPORT;
29 sin = ( ( struct sockaddr_in * ) sa );
30 comboot_resolv_addr = sin->sin_addr;
32 comboot_resolv_rc = 0;
35 static struct resolv_interface_operations comboot_resolv_ops = {
36 .done = comboot_resolv_done,
39 static struct resolv_interface comboot_resolver = {
41 .dest = &null_resolv.intf,
44 .op = &comboot_resolv_ops,
47 int comboot_resolv ( const char *name, struct in_addr *address ) {
50 comboot_resolv_rc = -EINPROGRESS;
52 if ( ( rc = resolv ( &comboot_resolver, name, NULL ) ) != 0 )
55 while ( comboot_resolv_rc == -EINPROGRESS )
58 *address = comboot_resolv_addr;
59 return comboot_resolv_rc;