Browse Source

[resolv] Use pass-through interfaces for name resolution multiplexer

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
53f273af90
1 changed files with 24 additions and 15 deletions
  1. 24
    15
      src/core/resolv.c

+ 24
- 15
src/core/resolv.c View File

180
 }
180
 }
181
 
181
 
182
 /**
182
 /**
183
- * Child resolved name
183
+ * Close name resolution multiplexer
184
  *
184
  *
185
  * @v mux		Name resolution multiplexer
185
  * @v mux		Name resolution multiplexer
186
- * @v sa		Completed socket address
186
+ * @v rc		Reason for close
187
  */
187
  */
188
-static void resmux_child_resolv_done ( struct resolv_mux *mux,
189
-				       struct sockaddr *sa ) {
190
-
191
-	DBGC ( mux, "RESOLV %p resolved \"%s\" to %s using method %s\n",
192
-	       mux, mux->name, sock_ntoa ( sa ), mux->resolver->name );
188
+static void resmux_close ( struct resolv_mux *mux, int rc ) {
193
 
189
 
194
-	/* Pass resolution to parent */
195
-	resolv_done ( &mux->parent, sa );
190
+	/* Shut down all interfaces */
191
+	intf_shutdown ( &mux->child, rc );
192
+	intf_shutdown ( &mux->parent, rc );
196
 }
193
 }
197
 
194
 
198
 /**
195
 /**
226
 	return;
223
 	return;
227
 
224
 
228
  finished:
225
  finished:
229
-	intf_shutdown ( &mux->parent, rc );
226
+	resmux_close ( mux, rc );
230
 }
227
 }
231
 
228
 
232
 /** Name resolution multiplexer child interface operations */
229
 /** Name resolution multiplexer child interface operations */
233
 static struct interface_operation resmux_child_op[] = {
230
 static struct interface_operation resmux_child_op[] = {
234
-	INTF_OP ( resolv_done, struct resolv_mux *, resmux_child_resolv_done ),
235
 	INTF_OP ( intf_close, struct resolv_mux *, resmux_child_close ),
231
 	INTF_OP ( intf_close, struct resolv_mux *, resmux_child_close ),
236
 };
232
 };
237
 
233
 
238
 /** Name resolution multiplexer child interface descriptor */
234
 /** Name resolution multiplexer child interface descriptor */
239
 static struct interface_descriptor resmux_child_desc =
235
 static struct interface_descriptor resmux_child_desc =
240
-	INTF_DESC ( struct resolv_mux, child, resmux_child_op );
236
+	INTF_DESC_PASSTHRU ( struct resolv_mux, child, resmux_child_op,
237
+			     parent );
238
+
239
+/** Name resolution multiplexer parent interface operations */
240
+static struct interface_operation resmux_parent_op[] = {
241
+	INTF_OP ( intf_close, struct resolv_mux *, resmux_close ),
242
+};
243
+
244
+/** Name resolution multiplexer parent interface descriptor */
245
+static struct interface_descriptor resmux_parent_desc =
246
+	INTF_DESC_PASSTHRU ( struct resolv_mux, parent, resmux_parent_op,
247
+			     child );
241
 
248
 
242
 /**
249
 /**
243
  * Start name resolution
250
  * Start name resolution
258
 	if ( ! mux )
265
 	if ( ! mux )
259
 		return -ENOMEM;
266
 		return -ENOMEM;
260
 	ref_init ( &mux->refcnt, NULL );
267
 	ref_init ( &mux->refcnt, NULL );
261
-	intf_init ( &mux->parent, &null_intf_desc, &mux->refcnt );
268
+	intf_init ( &mux->parent, &resmux_parent_desc, &mux->refcnt );
262
 	intf_init ( &mux->child, &resmux_child_desc, &mux->refcnt );
269
 	intf_init ( &mux->child, &resmux_child_desc, &mux->refcnt );
263
 	mux->resolver = table_start ( RESOLVERS );
270
 	mux->resolver = table_start ( RESOLVERS );
264
 	if ( sa )
271
 	if ( sa )
338
 
345
 
339
 /** Named socket opener data transfer interface descriptor */
346
 /** Named socket opener data transfer interface descriptor */
340
 static struct interface_descriptor named_xfer_desc =
347
 static struct interface_descriptor named_xfer_desc =
341
-	INTF_DESC ( struct named_socket, xfer, named_xfer_ops );
348
+	INTF_DESC_PASSTHRU ( struct named_socket, xfer, named_xfer_ops,
349
+			     resolv );
342
 
350
 
343
 /**
351
 /**
344
  * Name resolved
352
  * Name resolved
379
 
387
 
380
 /** Named socket opener resolver interface descriptor */
388
 /** Named socket opener resolver interface descriptor */
381
 static struct interface_descriptor named_resolv_desc =
389
 static struct interface_descriptor named_resolv_desc =
382
-	INTF_DESC ( struct named_socket, resolv, named_resolv_op );
390
+	INTF_DESC_PASSTHRU ( struct named_socket, resolv, named_resolv_op,
391
+			     xfer );
383
 
392
 
384
 /**
393
 /**
385
  * Open named socket
394
  * Open named socket

Loading…
Cancel
Save