mirror of
https://github.com/ipxe/ipxe
synced 2025-12-25 17:12:40 +03:00
[interface] Convert all data-xfer interfaces to generic interfaces
Remove data-xfer as an interface type, and replace data-xfer interfaces with generic interfaces supporting the data-xfer methods. Filter interfaces (as used by the TLS layer) are handled using the generic pass-through interface capability. A side-effect of this is that deliver_raw() no longer exists as a data-xfer method. (In practice this doesn't lose any efficiency, since there are no instances within the current codebase where xfer_deliver_raw() is used to pass data to an interface supporting the deliver_raw() method.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -15,33 +15,24 @@
|
||||
|
||||
struct hw {
|
||||
struct refcnt refcnt;
|
||||
struct xfer_interface xfer;
|
||||
struct interface xfer;
|
||||
struct process process;
|
||||
};
|
||||
|
||||
static const char hw_msg[] = "Hello world!\n";
|
||||
|
||||
static void hw_finished ( struct hw *hw, int rc ) {
|
||||
xfer_nullify ( &hw->xfer );
|
||||
xfer_close ( &hw->xfer, rc );
|
||||
intf_shutdown ( &hw->xfer, rc );
|
||||
process_del ( &hw->process );
|
||||
}
|
||||
|
||||
static void hw_xfer_close ( struct xfer_interface *xfer, int rc ) {
|
||||
struct hw *hw = container_of ( xfer, struct hw, xfer );
|
||||
|
||||
hw_finished ( hw, rc );
|
||||
}
|
||||
|
||||
static struct xfer_interface_operations hw_xfer_operations = {
|
||||
.close = hw_xfer_close,
|
||||
.vredirect = ignore_xfer_vredirect,
|
||||
.window = unlimited_xfer_window,
|
||||
.alloc_iob = default_xfer_alloc_iob,
|
||||
.deliver_iob = xfer_deliver_as_raw,
|
||||
.deliver_raw = ignore_xfer_deliver_raw,
|
||||
static struct interface_operation hw_xfer_operations[] = {
|
||||
INTF_OP ( intf_close, struct hw *, hw_finished ),
|
||||
};
|
||||
|
||||
static struct interface_descriptor hw_xfer_desc =
|
||||
INTF_DESC ( struct hw, xfer, hw_xfer_operations );
|
||||
|
||||
static void hw_step ( struct process *process ) {
|
||||
struct hw *hw = container_of ( process, struct hw, process );
|
||||
int rc;
|
||||
@@ -52,7 +43,7 @@ static void hw_step ( struct process *process ) {
|
||||
}
|
||||
}
|
||||
|
||||
static int hw_open ( struct xfer_interface *xfer, struct uri *uri __unused ) {
|
||||
static int hw_open ( struct interface *xfer, struct uri *uri __unused ) {
|
||||
struct hw *hw;
|
||||
|
||||
/* Allocate and initialise structure */
|
||||
@@ -60,11 +51,11 @@ static int hw_open ( struct xfer_interface *xfer, struct uri *uri __unused ) {
|
||||
if ( ! hw )
|
||||
return -ENOMEM;
|
||||
ref_init ( &hw->refcnt, NULL );
|
||||
xfer_init ( &hw->xfer, &hw_xfer_operations, &hw->refcnt );
|
||||
intf_init ( &hw->xfer, &hw_xfer_desc, &hw->refcnt );
|
||||
process_init ( &hw->process, hw_step, &hw->refcnt );
|
||||
|
||||
/* Attach parent interface, mortalise self, and return */
|
||||
xfer_plug_plug ( &hw->xfer, xfer );
|
||||
intf_plug_plug ( &hw->xfer, xfer );
|
||||
ref_put ( &hw->refcnt );
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user