5 #include <ipxe/process.h>
6 #include <ipxe/resolv.h>
8 FILE_LICENCE ( GPL2_OR_LATER );
10 struct comboot_resolver {
11 struct interface intf;
16 static void comboot_resolv_close ( struct comboot_resolver *comboot_resolver,
18 comboot_resolver->rc = rc;
19 intf_shutdown ( &comboot_resolver->intf, rc );
22 static void comboot_resolv_done ( struct comboot_resolver *comboot_resolver,
23 struct sockaddr *sa ) {
24 struct sockaddr_in *sin;
26 if ( sa->sa_family == AF_INET ) {
27 sin = ( ( struct sockaddr_in * ) sa );
28 comboot_resolver->addr = sin->sin_addr;
32 static struct interface_operation comboot_resolv_op[] = {
33 INTF_OP ( intf_close, struct comboot_resolver *, comboot_resolv_close ),
34 INTF_OP ( resolv_done, struct comboot_resolver *, comboot_resolv_done ),
37 static struct interface_descriptor comboot_resolv_desc =
38 INTF_DESC ( struct comboot_resolver, intf, comboot_resolv_op );
40 static struct comboot_resolver comboot_resolver = {
41 .intf = INTF_INIT ( comboot_resolv_desc ),
44 int comboot_resolv ( const char *name, struct in_addr *address ) {
47 comboot_resolver.rc = -EINPROGRESS;
48 comboot_resolver.addr.s_addr = 0;
50 if ( ( rc = resolv ( &comboot_resolver.intf, name, NULL ) ) != 0 )
53 while ( comboot_resolver.rc == -EINPROGRESS )
56 if ( ! comboot_resolver.addr.s_addr )
59 *address = comboot_resolver.addr;
60 return comboot_resolver.rc;