Преглед на файлове

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown преди 7 години
родител
ревизия
53f273af90
променени са 1 файла, в които са добавени 24 реда и са изтрити 15 реда
  1. 24
    15
      src/core/resolv.c

+ 24
- 15
src/core/resolv.c Целия файл

@@ -180,19 +180,16 @@ static int resmux_try ( struct resolv_mux *mux ) {
180 180
 }
181 181
 
182 182
 /**
183
- * Child resolved name
183
+ * Close name resolution multiplexer
184 184
  *
185 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,18 +223,28 @@ static void resmux_child_close ( struct resolv_mux *mux, int rc ) {
226 223
 	return;
227 224
 
228 225
  finished:
229
-	intf_shutdown ( &mux->parent, rc );
226
+	resmux_close ( mux, rc );
230 227
 }
231 228
 
232 229
 /** Name resolution multiplexer child interface operations */
233 230
 static struct interface_operation resmux_child_op[] = {
234
-	INTF_OP ( resolv_done, struct resolv_mux *, resmux_child_resolv_done ),
235 231
 	INTF_OP ( intf_close, struct resolv_mux *, resmux_child_close ),
236 232
 };
237 233
 
238 234
 /** Name resolution multiplexer child interface descriptor */
239 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 250
  * Start name resolution
@@ -258,7 +265,7 @@ int resolv ( struct interface *resolv, const char *name,
258 265
 	if ( ! mux )
259 266
 		return -ENOMEM;
260 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 269
 	intf_init ( &mux->child, &resmux_child_desc, &mux->refcnt );
263 270
 	mux->resolver = table_start ( RESOLVERS );
264 271
 	if ( sa )
@@ -338,7 +345,8 @@ static struct interface_operation named_xfer_ops[] = {
338 345
 
339 346
 /** Named socket opener data transfer interface descriptor */
340 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 352
  * Name resolved
@@ -379,7 +387,8 @@ static struct interface_operation named_resolv_op[] = {
379 387
 
380 388
 /** Named socket opener resolver interface descriptor */
381 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 394
  * Open named socket

Loading…
Отказ
Запис