|  | @@ -0,0 +1,78 @@
 | 
		
	
		
			
			|  | 1 | +/*
 | 
		
	
		
			
			|  | 2 | + * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
 | 
		
	
		
			
			|  | 3 | + *
 | 
		
	
		
			
			|  | 4 | + * This program is free software; you can redistribute it and/or
 | 
		
	
		
			
			|  | 5 | + * modify it under the terms of the GNU General Public License as
 | 
		
	
		
			
			|  | 6 | + * published by the Free Software Foundation; either version 2 of the
 | 
		
	
		
			
			|  | 7 | + * License, or any later version.
 | 
		
	
		
			
			|  | 8 | + *
 | 
		
	
		
			
			|  | 9 | + * This program is distributed in the hope that it will be useful, but
 | 
		
	
		
			
			|  | 10 | + * WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
		
	
		
			
			|  | 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
		
	
		
			
			|  | 12 | + * General Public License for more details.
 | 
		
	
		
			
			|  | 13 | + *
 | 
		
	
		
			
			|  | 14 | + * You should have received a copy of the GNU General Public License
 | 
		
	
		
			
			|  | 15 | + * along with this program; if not, write to the Free Software
 | 
		
	
		
			
			|  | 16 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
		
	
		
			
			|  | 17 | + */
 | 
		
	
		
			
			|  | 18 | +
 | 
		
	
		
			
			|  | 19 | +#include <gpxe/xfer.h>
 | 
		
	
		
			
			|  | 20 | +#include <gpxe/filter.h>
 | 
		
	
		
			
			|  | 21 | +
 | 
		
	
		
			
			|  | 22 | +/** @file
 | 
		
	
		
			
			|  | 23 | + *
 | 
		
	
		
			
			|  | 24 | + * Data transfer filters
 | 
		
	
		
			
			|  | 25 | + *
 | 
		
	
		
			
			|  | 26 | + */
 | 
		
	
		
			
			|  | 27 | +
 | 
		
	
		
			
			|  | 28 | +/*
 | 
		
	
		
			
			|  | 29 | + * Pass-through methods to be used by filters which don't want to
 | 
		
	
		
			
			|  | 30 | + * intercept all events.
 | 
		
	
		
			
			|  | 31 | + *
 | 
		
	
		
			
			|  | 32 | + */
 | 
		
	
		
			
			|  | 33 | +
 | 
		
	
		
			
			|  | 34 | +void filter_close ( struct xfer_interface *xfer, int rc ) {
 | 
		
	
		
			
			|  | 35 | +	struct xfer_interface *other = filter_other_half ( xfer );
 | 
		
	
		
			
			|  | 36 | +
 | 
		
	
		
			
			|  | 37 | +	xfer_close ( other, rc );
 | 
		
	
		
			
			|  | 38 | +}
 | 
		
	
		
			
			|  | 39 | +
 | 
		
	
		
			
			|  | 40 | +int filter_vredirect ( struct xfer_interface *xfer, int type,
 | 
		
	
		
			
			|  | 41 | +			va_list args ) {
 | 
		
	
		
			
			|  | 42 | +	struct xfer_interface *other = filter_other_half ( xfer );
 | 
		
	
		
			
			|  | 43 | +
 | 
		
	
		
			
			|  | 44 | +	return xfer_vredirect ( other, type, args );
 | 
		
	
		
			
			|  | 45 | +}
 | 
		
	
		
			
			|  | 46 | +
 | 
		
	
		
			
			|  | 47 | +int filter_seek ( struct xfer_interface *xfer, off_t offset, int whence ) {
 | 
		
	
		
			
			|  | 48 | +	struct xfer_interface *other = filter_other_half ( xfer );
 | 
		
	
		
			
			|  | 49 | +
 | 
		
	
		
			
			|  | 50 | +	return xfer_seek ( other, offset, whence );
 | 
		
	
		
			
			|  | 51 | +}
 | 
		
	
		
			
			|  | 52 | +
 | 
		
	
		
			
			|  | 53 | +size_t filter_window ( struct xfer_interface *xfer ) {
 | 
		
	
		
			
			|  | 54 | +	struct xfer_interface *other = filter_other_half ( xfer );
 | 
		
	
		
			
			|  | 55 | +
 | 
		
	
		
			
			|  | 56 | +	return xfer_window ( other );
 | 
		
	
		
			
			|  | 57 | +}
 | 
		
	
		
			
			|  | 58 | +
 | 
		
	
		
			
			|  | 59 | +struct io_buffer * filter_alloc_iob ( struct xfer_interface *xfer,
 | 
		
	
		
			
			|  | 60 | +				      size_t len ) {
 | 
		
	
		
			
			|  | 61 | +	struct xfer_interface *other = filter_other_half ( xfer );
 | 
		
	
		
			
			|  | 62 | +
 | 
		
	
		
			
			|  | 63 | +	return xfer_alloc_iob ( other, len );
 | 
		
	
		
			
			|  | 64 | +}
 | 
		
	
		
			
			|  | 65 | +
 | 
		
	
		
			
			|  | 66 | +int filter_deliver_iob ( struct xfer_interface *xfer, struct io_buffer *iobuf,
 | 
		
	
		
			
			|  | 67 | +			 struct xfer_metadata *meta ) {
 | 
		
	
		
			
			|  | 68 | +	struct xfer_interface *other = filter_other_half ( xfer );
 | 
		
	
		
			
			|  | 69 | +
 | 
		
	
		
			
			|  | 70 | +	return xfer_deliver_iob_meta ( other, iobuf, meta );
 | 
		
	
		
			
			|  | 71 | +}
 | 
		
	
		
			
			|  | 72 | +
 | 
		
	
		
			
			|  | 73 | +int filter_deliver_raw ( struct xfer_interface *xfer, const void *data,
 | 
		
	
		
			
			|  | 74 | +			 size_t len ) {
 | 
		
	
		
			
			|  | 75 | +	struct xfer_interface *other = filter_other_half ( xfer );
 | 
		
	
		
			
			|  | 76 | +
 | 
		
	
		
			
			|  | 77 | +	return xfer_deliver_raw ( other, data, len );
 | 
		
	
		
			
			|  | 78 | +}
 |