comboot_resolv.c

Go to the documentation of this file.
00001 #include <errno.h>
00002 #include <comboot.h>
00003 #include <gpxe/in.h>
00004 #include <gpxe/list.h>
00005 #include <gpxe/process.h>
00006 #include <gpxe/resolv.h>
00007 
00008 FILE_LICENCE ( GPL2_OR_LATER );
00009 
00010 static int comboot_resolv_rc;
00011 static struct in_addr comboot_resolv_addr;
00012 
00013 static void comboot_resolv_done ( struct resolv_interface *resolv,
00014                                   struct sockaddr *sa, int rc ) {
00015         struct sockaddr_in *sin;
00016 
00017         resolv_unplug ( resolv );
00018 
00019         if ( rc != 0 ) {
00020                 comboot_resolv_rc = rc;
00021                 return;
00022         }
00023 
00024         if ( sa->sa_family != AF_INET ) {
00025                 comboot_resolv_rc = -EAFNOSUPPORT;
00026                 return;
00027         }
00028 
00029         sin = ( ( struct sockaddr_in * ) sa );
00030         comboot_resolv_addr = sin->sin_addr;
00031 
00032         comboot_resolv_rc = 0;
00033 }
00034 
00035 static struct resolv_interface_operations comboot_resolv_ops = {
00036         .done = comboot_resolv_done,
00037 };
00038 
00039 static struct resolv_interface comboot_resolver = {
00040         .intf = {
00041                 .dest = &null_resolv.intf,
00042                 .refcnt = NULL,
00043         },
00044         .op = &comboot_resolv_ops,
00045 };
00046 
00047 int comboot_resolv ( const char *name, struct in_addr *address ) {
00048         int rc;
00049 
00050         comboot_resolv_rc = -EINPROGRESS;
00051 
00052         if ( ( rc = resolv ( &comboot_resolver, name, NULL ) ) != 0 )
00053                 return rc;
00054 
00055         while ( comboot_resolv_rc == -EINPROGRESS )
00056                 step();
00057 
00058         *address = comboot_resolv_addr;
00059         return comboot_resolv_rc;
00060 }

Generated on Tue Apr 6 20:00:51 2010 for gPXE by  doxygen 1.5.7.1