aboutsummaryrefslogtreecommitdiff
path: root/src/core
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 /src/core
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>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/blocktrans.c4
-rw-r--r--src/core/interface.c17
2 files changed, 18 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