mirror of
https://github.com/ipxe/ipxe
synced 2025-12-19 11:00:27 +03:00
[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>
This commit is contained in:
@@ -242,9 +242,7 @@ int block_translate ( struct interface *block, userptr_t buffer, size_t size ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Attach to interfaces, mortalise self, and return */
|
/* Attach to interfaces, mortalise self, and return */
|
||||||
assert ( block->dest != &null_intf );
|
intf_insert ( block, &blktrans->block, &blktrans->xfer );
|
||||||
intf_plug_plug ( &blktrans->xfer, block->dest );
|
|
||||||
intf_plug_plug ( &blktrans->block, block );
|
|
||||||
ref_put ( &blktrans->refcnt );
|
ref_put ( &blktrans->refcnt );
|
||||||
|
|
||||||
DBGC2 ( blktrans, "BLKTRANS %p created", blktrans );
|
DBGC2 ( blktrans, "BLKTRANS %p created", blktrans );
|
||||||
|
|||||||
@@ -390,6 +390,23 @@ void intfs_restart ( int rc, ... ) {
|
|||||||
va_end ( intfs );
|
va_end ( intfs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Poke an object interface
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -169,6 +169,8 @@ extern void intfs_shutdown ( int rc, ... ) __attribute__ (( sentinel ));
|
|||||||
extern void intf_restart ( struct interface *intf, int rc );
|
extern void intf_restart ( struct interface *intf, int rc );
|
||||||
extern void intfs_vrestart ( va_list intfs, int rc );
|
extern void intfs_vrestart ( va_list intfs, int rc );
|
||||||
extern void intfs_restart ( int rc, ... ) __attribute__ (( sentinel ));
|
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,
|
extern void intf_poke ( struct interface *intf,
|
||||||
void ( type ) ( struct interface *intf ) );
|
void ( type ) ( struct interface *intf ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user