aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2020-12-07 13:49:47 +0000
committerMichael Brown <mcb30@ipxe.org>2020-12-07 13:50:24 +0000
commit09fe2bbd343a46010e89d848e5887bfb5fc3f6f6 (patch)
tree7d34c1b508c2cf63a3cc298bb2a2a595134fb243
parentcb0ba2f8253bc4ed3b301928c4a84d6ca1e7593b (diff)
downloadipxe-09fe2bbd343a46010e89d848e5887bfb5fc3f6f6.zip
ipxe-09fe2bbd343a46010e89d848e5887bfb5fc3f6f6.tar.gz
ipxe-09fe2bbd343a46010e89d848e5887bfb5fc3f6f6.tar.bz2
[interface] Provide intf_insert() to insert a filter interface
Generalise the filter interface insertion logic from block_translate() and expose as intf_insert(), allowing a filter interface to be inserted on any existing interface. Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/core/blocktrans.c4
-rw-r--r--src/core/interface.c17
-rw-r--r--src/include/ipxe/interface.h2
3 files changed, 20 insertions, 3 deletions
diff --git a/src/core/blocktrans.c b/src/core/blocktrans.c
index 3f32f9c..f9dcb95 100644
--- a/src/core/blocktrans.c
+++ b/src/core/blocktrans.c
@@ -242,9 +242,7 @@ int block_translate ( struct interface *block, userptr_t buffer, size_t size ) {
}
/* Attach to interfaces, mortalise self, and return */
- assert ( block->dest != &null_intf );
- intf_plug_plug ( &blktrans->xfer, block->dest );
- intf_plug_plug ( &blktrans->block, block );
+ intf_insert ( block, &blktrans->block, &blktrans->xfer );
ref_put ( &blktrans->refcnt );
DBGC2 ( blktrans, "BLKTRANS %p created", blktrans );
diff --git a/src/core/interface.c b/src/core/interface.c
index 05e7e47..34a4180 100644
--- a/src/core/interface.c
+++ b/src/core/interface.c
@@ -391,6 +391,23 @@ void intfs_restart ( int rc, ... ) {
}
/**
+ * Insert a filter interface
+ *
+ * @v intf Object interface
+ * @v upper Upper end of filter
+ * @v lower Lower end of filter
+ */
+void intf_insert ( struct interface *intf, struct interface *upper,
+ struct interface *lower ) {
+ struct interface *dest = intf->dest;
+
+ intf_get ( dest );
+ intf_plug_plug ( intf, upper );
+ intf_plug_plug ( lower, dest );
+ intf_put ( dest );
+}
+
+/**
* Poke an object interface
*
* @v intf Object interface
diff --git a/src/include/ipxe/interface.h b/src/include/ipxe/interface.h
index 9281aee..19f58a4 100644
--- a/src/include/ipxe/interface.h
+++ b/src/include/ipxe/interface.h
@@ -169,6 +169,8 @@ extern void intfs_shutdown ( int rc, ... ) __attribute__ (( sentinel ));
extern void intf_restart ( struct interface *intf, int rc );
extern void intfs_vrestart ( va_list intfs, int rc );
extern void intfs_restart ( int rc, ... ) __attribute__ (( sentinel ));
+extern void intf_insert ( struct interface *intf, struct interface *upper,
+ struct interface *lower );
extern void intf_poke ( struct interface *intf,
void ( type ) ( struct interface *intf ) );