iPXE
Data Structures | Defines | Functions
resolv.h File Reference

Name resolution. More...

#include <ipxe/interface.h>
#include <ipxe/tables.h>

Go to the source code of this file.

Data Structures

struct  resolver
 A name resolver. More...

Defines

#define RESOLV_NUMERIC   01
 Numeric resolver priority.
#define RESOLV_NORMAL   02
 Normal resolver priority.
#define RESOLVERS   __table ( struct resolver, "resolvers" )
 Resolvers table.
#define __resolver(resolv_order)   __table_entry ( RESOLVERS, resolv_order )
 Register as a name resolver.
#define resolv_done_TYPE(object_type)   typeof ( void ( object_type, struct sockaddr *sa ) )

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
void resolv_done (struct interface *intf, struct sockaddr *sa)
 Name resolved.
int resolv (struct interface *resolv, const char *name, struct sockaddr *sa)
 Start name resolution.

Detailed Description

Name resolution.

Definition in file resolv.h.


Define Documentation

#define RESOLV_NUMERIC   01

Numeric resolver priority.

Definition at line 33 of file resolv.h.

#define RESOLV_NORMAL   02

Normal resolver priority.

Definition at line 36 of file resolv.h.

#define RESOLVERS   __table ( struct resolver, "resolvers" )

Resolvers table.

Definition at line 39 of file resolv.h.

Referenced by resmux_child_close(), and resolv().

#define __resolver (   resolv_order)    __table_entry ( RESOLVERS, resolv_order )

Register as a name resolver.

Definition at line 42 of file resolv.h.

#define resolv_done_TYPE (   object_type)    typeof ( void ( object_type, struct sockaddr *sa ) )

Definition at line 45 of file resolv.h.

Referenced by resolv_done().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
void resolv_done ( struct interface intf,
struct sockaddr sa 
)

Name resolved.

Parameters:
intfObject interface
saCompleted socket address (if successful)

Definition at line 55 of file resolv.c.

References DBGC, dest, INTF_COL, intf_get_dest_op, INTF_INTF_DBG, INTF_INTF_FMT, intf_object(), intf_put(), op, resolv_done(), and resolv_done_TYPE.

Referenced by dns_resolved(), numeric_step(), and resolv_done().

                                                                 {
        struct interface *dest;
        resolv_done_TYPE ( void * ) *op =
                intf_get_dest_op ( intf, resolv_done, &dest );
        void *object = intf_object ( dest );

        DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " resolv_done\n",
               INTF_INTF_DBG ( intf, dest ) );

        if ( op ) {
                op ( object, sa );
        } else {
                /* Default is to ignore resolutions */
        }

        intf_put ( dest );
}
int resolv ( struct interface resolv,
const char *  name,
struct sockaddr sa 
)

Start name resolution.

Parameters:
resolvName resolution interface
nameName to resolve
saSocket address to complete
Return values:
rcReturn status code

Definition at line 257 of file resolv.c.

References resolv_mux::child, DBGC, ENOMEM, intf_init(), intf_plug_plug(), memcpy(), resolv_mux::name, NULL, resolv_mux::parent, rc, ref_init, ref_put, resolv_mux::refcnt, resmux_try(), resolv_mux::resolver, RESOLVERS, resolv_mux::sa, strlen(), table_start, and zalloc().

Referenced by comboot_resolv(), resolv_setting(), and xfer_open_named_socket().

                                   {
        struct resolv_mux *mux;
        size_t name_len = ( strlen ( name ) + 1 );
        int rc;

        /* Allocate and initialise structure */
        mux = zalloc ( sizeof ( *mux ) + name_len );
        if ( ! mux )
                return -ENOMEM;
        ref_init ( &mux->refcnt, NULL );
        intf_init ( &mux->parent, &resmux_parent_desc, &mux->refcnt );
        intf_init ( &mux->child, &resmux_child_desc, &mux->refcnt );
        mux->resolver = table_start ( RESOLVERS );
        if ( sa )
                memcpy ( &mux->sa, sa, sizeof ( mux->sa ) );
        memcpy ( mux->name, name, name_len );

        DBGC ( mux, "RESOLV %p attempting to resolve \"%s\"\n", mux, name );

        /* Start first resolver in chain.  There will always be at
         * least one resolver (the numeric resolver), so no need to
         * check for the zero-resolvers-available case.
         */
        if ( ( rc = resmux_try ( mux ) ) != 0 )
                goto err;

        /* Attach parent interface, mortalise self, and return */
        intf_plug_plug ( &mux->parent, resolv );
        ref_put ( &mux->refcnt );
        return 0;

 err:
        ref_put ( &mux->refcnt );
        return rc;      
}