diff options
author | Michael Brown <mcb30@ipxe.org> | 2017-09-06 11:43:22 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2017-09-06 11:43:22 +0100 |
commit | 53f273af90df0b88a406d5eadf41b4203d516a4a (patch) | |
tree | 2c2ddec5ad234b141b33de6e5e3c0e2ba3095507 /src | |
parent | 8047baf7c66601f4e3aa14a3dcb60f3679f03a79 (diff) | |
download | ipxe-53f273af90df0b88a406d5eadf41b4203d516a4a.zip ipxe-53f273af90df0b88a406d5eadf41b4203d516a4a.tar.gz ipxe-53f273af90df0b88a406d5eadf41b4203d516a4a.tar.bz2 |
[resolv] Use pass-through interfaces for name resolution multiplexer
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/resolv.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/core/resolv.c b/src/core/resolv.c index 1e3182b..fab8def 100644 --- a/src/core/resolv.c +++ b/src/core/resolv.c @@ -180,19 +180,16 @@ static int resmux_try ( struct resolv_mux *mux ) { } /** - * Child resolved name + * Close name resolution multiplexer * * @v mux Name resolution multiplexer - * @v sa Completed socket address + * @v rc Reason for close */ -static void resmux_child_resolv_done ( struct resolv_mux *mux, - struct sockaddr *sa ) { - - DBGC ( mux, "RESOLV %p resolved \"%s\" to %s using method %s\n", - mux, mux->name, sock_ntoa ( sa ), mux->resolver->name ); +static void resmux_close ( struct resolv_mux *mux, int rc ) { - /* Pass resolution to parent */ - resolv_done ( &mux->parent, sa ); + /* Shut down all interfaces */ + intf_shutdown ( &mux->child, rc ); + intf_shutdown ( &mux->parent, rc ); } /** @@ -226,18 +223,28 @@ static void resmux_child_close ( struct resolv_mux *mux, int rc ) { return; finished: - intf_shutdown ( &mux->parent, rc ); + resmux_close ( mux, rc ); } /** Name resolution multiplexer child interface operations */ static struct interface_operation resmux_child_op[] = { - INTF_OP ( resolv_done, struct resolv_mux *, resmux_child_resolv_done ), INTF_OP ( intf_close, struct resolv_mux *, resmux_child_close ), }; /** Name resolution multiplexer child interface descriptor */ static struct interface_descriptor resmux_child_desc = - INTF_DESC ( struct resolv_mux, child, resmux_child_op ); + INTF_DESC_PASSTHRU ( struct resolv_mux, child, resmux_child_op, + parent ); + +/** Name resolution multiplexer parent interface operations */ +static struct interface_operation resmux_parent_op[] = { + INTF_OP ( intf_close, struct resolv_mux *, resmux_close ), +}; + +/** Name resolution multiplexer parent interface descriptor */ +static struct interface_descriptor resmux_parent_desc = + INTF_DESC_PASSTHRU ( struct resolv_mux, parent, resmux_parent_op, + child ); /** * Start name resolution @@ -258,7 +265,7 @@ int resolv ( struct interface *resolv, const char *name, if ( ! mux ) return -ENOMEM; ref_init ( &mux->refcnt, NULL ); - intf_init ( &mux->parent, &null_intf_desc, &mux->refcnt ); + 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 ) @@ -338,7 +345,8 @@ static struct interface_operation named_xfer_ops[] = { /** Named socket opener data transfer interface descriptor */ static struct interface_descriptor named_xfer_desc = - INTF_DESC ( struct named_socket, xfer, named_xfer_ops ); + INTF_DESC_PASSTHRU ( struct named_socket, xfer, named_xfer_ops, + resolv ); /** * Name resolved @@ -379,7 +387,8 @@ static struct interface_operation named_resolv_op[] = { /** Named socket opener resolver interface descriptor */ static struct interface_descriptor named_resolv_desc = - INTF_DESC ( struct named_socket, resolv, named_resolv_op ); + INTF_DESC_PASSTHRU ( struct named_socket, resolv, named_resolv_op, + xfer ); /** * Open named socket |