#include <gpxe/refcnt.h>
#include <gpxe/interface.h>
#include <gpxe/tables.h>
#include <gpxe/socket.h>
Go to the source code of this file.
Data Structures | |
| struct | resolv_interface_operations |
| Name resolution interface operations. More... | |
| struct | resolv_interface |
| A name resolution interface. More... | |
| 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. | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static void | resolv_init (struct resolv_interface *resolv, struct resolv_interface_operations *op, struct refcnt *refcnt) |
| Initialise a name resolution interface. | |
| static struct resolv_interface * | intf_to_resolv (struct interface *intf) |
| Get name resolution interface from generic object communication interface. | |
| static struct resolv_interface * | resolv_get_dest (struct resolv_interface *resolv) |
| Get reference to destination name resolution interface. | |
| static void | resolv_put (struct resolv_interface *resolv) |
| Drop reference to name resolution interface. | |
| static void | resolv_plug (struct resolv_interface *resolv, struct resolv_interface *dest) |
| Plug a name resolution interface into a new destination interface. | |
| static void | resolv_plug_plug (struct resolv_interface *a, struct resolv_interface *b) |
| Plug two name resolution interfaces together. | |
| static void | resolv_unplug (struct resolv_interface *resolv) |
| Unplug a name resolution interface. | |
| static void | resolv_nullify (struct resolv_interface *resolv) |
| Stop using a name resolution interface. | |
| void | resolv_done (struct resolv_interface *resolv, struct sockaddr *sa, int rc) |
| Name resolution completed. | |
| void | ignore_resolv_done (struct resolv_interface *resolv, struct sockaddr *sa, int rc) |
| int | resolv (struct resolv_interface *resolv, const char *name, struct sockaddr *sa) |
| Start name resolution. | |
Variables | |
| struct resolv_interface | null_resolv |
| Null name resolution interface. | |
| struct resolv_interface_operations | null_resolv_ops |
| Null name resolution interface operations. | |
Definition in file resolv.h.
| #define RESOLVERS __table ( struct resolver, "resolvers" ) |
Resolvers table.
Definition at line 155 of file resolv.h.
Referenced by resolv(), and resolv_mux_done().
| #define __resolver | ( | resolv_order | ) | __table_entry ( RESOLVERS, resolv_order ) |
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static void resolv_init | ( | struct resolv_interface * | resolv, | |
| struct resolv_interface_operations * | op, | |||
| struct refcnt * | refcnt | |||
| ) | [inline, static] |
Initialise a name resolution interface.
| resolv | Name resolution interface | |
| op | Name resolution interface operations | |
| refcnt | Containing object reference counter, or NULL |
Definition at line 49 of file resolv.h.
References interface::dest, resolv_interface::intf, null_resolv, resolv_interface::op, and interface::refcnt.
Referenced by dns_resolv(), numeric_resolv(), resolv(), and xfer_open_named_socket().
00051 { 00052 resolv->intf.dest = &null_resolv.intf; 00053 resolv->intf.refcnt = refcnt; 00054 resolv->op = op; 00055 }
| static struct resolv_interface* intf_to_resolv | ( | struct interface * | intf | ) | [static, read] |
Get name resolution interface from generic object communication interface.
| intf | Generic object communication interface |
| resolv | Name resolution interface |
Definition at line 64 of file resolv.h.
References container_of.
Referenced by resolv_get_dest().
00064 { 00065 return container_of ( intf, struct resolv_interface, intf ); 00066 }
| static struct resolv_interface* resolv_get_dest | ( | struct resolv_interface * | resolv | ) | [static, read] |
Get reference to destination name resolution interface.
| resolv | Name resolution interface |
| dest | Destination interface |
Definition at line 75 of file resolv.h.
References intf_to_resolv().
Referenced by resolv_done().
00075 { 00076 return intf_to_resolv ( intf_get ( resolv->intf.dest ) ); 00077 }
| static void resolv_put | ( | struct resolv_interface * | resolv | ) | [inline, static] |
| static void resolv_plug | ( | struct resolv_interface * | resolv, | |
| struct resolv_interface * | dest | |||
| ) | [inline, static] |
| static void resolv_plug_plug | ( | struct resolv_interface * | a, | |
| struct resolv_interface * | b | |||
| ) | [inline, static] |
Plug two name resolution interfaces together.
Definition at line 107 of file resolv.h.
References plug_plug().
Referenced by dns_resolv(), numeric_resolv(), and resolv().
| static void resolv_unplug | ( | struct resolv_interface * | resolv | ) | [inline, static] |
Unplug a name resolution interface.
| resolv | Name resolution interface |
Definition at line 117 of file resolv.h.
References resolv_interface::intf, null_resolv, and plug().
Referenced by comboot_resolv_done(), resolv_done(), and resolv_mux_done().
00117 { 00118 plug ( &resolv->intf, &null_resolv.intf ); 00119 }
| static void resolv_nullify | ( | struct resolv_interface * | resolv | ) | [inline, static] |
Stop using a name resolution interface.
| resolv | Name resolution interface |
Definition at line 129 of file resolv.h.
References null_resolv_ops, and resolv_interface::op.
Referenced by named_done().
00129 { 00130 resolv->op = &null_resolv_ops; 00131 };
| void resolv_done | ( | struct resolv_interface * | resolv, | |
| struct sockaddr * | sa, | |||
| int | rc | |||
| ) |
Name resolution completed.
| resolv | Name resolution interface | |
| sa | Completed socket address (if successful) | |
| rc | Final status code |
Definition at line 51 of file resolv.c.
References dest, resolv_interface_operations::done, resolv_interface::op, resolv_get_dest(), resolv_put(), and resolv_unplug().
Referenced by dns_done(), numeric_step(), and resolv_mux_done().
00052 { 00053 struct resolv_interface *dest = resolv_get_dest ( resolv ); 00054 00055 resolv_unplug ( resolv ); 00056 dest->op->done ( dest, sa, rc ); 00057 resolv_put ( dest ); 00058 }
| void ignore_resolv_done | ( | struct resolv_interface * | resolv, | |
| struct sockaddr * | sa, | |||
| int | rc | |||
| ) |
| int resolv | ( | struct resolv_interface * | resolv, | |
| const char * | name, | |||
| struct sockaddr * | sa | |||
| ) |
Start name resolution.
| resolv | Name resolution interface | |
| name | Name to resolve | |
| sa | Socket address to complete |
| rc | Return status code |
Definition at line 249 of file resolv.c.
References resolv_mux::child, DBGC, ENOMEM, memcpy, resolv_mux::name, resolv_mux::parent, ref_put(), resolv_mux::refcnt, resolv_init(), resolv_mux_try(), resolv_plug_plug(), resolv_mux::resolver, RESOLVERS, resolv_mux::sa, strlen(), table_start, and zalloc().
Referenced by comboot_resolv(), and xfer_open_named_socket().
00250 { 00251 struct resolv_mux *mux; 00252 size_t name_len = ( strlen ( name ) + 1 ); 00253 int rc; 00254 00255 /* Allocate and initialise structure */ 00256 mux = zalloc ( sizeof ( *mux ) + name_len ); 00257 if ( ! mux ) 00258 return -ENOMEM; 00259 resolv_init ( &mux->parent, &null_resolv_ops, &mux->refcnt ); 00260 resolv_init ( &mux->child, &resolv_mux_child_ops, &mux->refcnt ); 00261 mux->resolver = table_start ( RESOLVERS ); 00262 memcpy ( &mux->sa, sa, sizeof ( mux->sa ) ); 00263 memcpy ( mux->name, name, name_len ); 00264 00265 DBGC ( mux, "RESOLV %p attempting to resolve \"%s\"\n", mux, name ); 00266 00267 /* Start first resolver in chain. There will always be at 00268 * least one resolver (the numeric resolver), so no need to 00269 * check for the zero-resolvers-available case. 00270 */ 00271 if ( ( rc = resolv_mux_try ( mux ) ) != 0 ) 00272 goto err; 00273 00274 /* Attach parent interface, mortalise self, and return */ 00275 resolv_plug_plug ( &mux->parent, resolv ); 00276 ref_put ( &mux->refcnt ); 00277 return 0; 00278 00279 err: 00280 ref_put ( &mux->refcnt ); 00281 return rc; 00282 }
struct resolv_interface null_resolv [read] |
Null name resolution interface.
Definition at line 165 of file resolv.h.
Referenced by resolv_init(), and resolv_unplug().
struct resolv_interface_operations null_resolv_ops [read] |
Null name resolution interface operations.
Definition at line 164 of file resolv.h.
Referenced by dns_resolv(), and resolv_nullify().
1.5.7.1