You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

filter.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef _GPXE_FILTER_H
  2. #define _GPXE_FILTER_H
  3. /** @file
  4. *
  5. * Data transfer filters
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <stddef.h>
  10. #include <gpxe/xfer.h>
  11. /**
  12. * Half of a data transfer filter
  13. *
  14. * Embed two of these structures within a structure implementing a
  15. * data transfer filter, and intialise with filter_init(). You can
  16. * then use the filter_xxx() methods as the data transfer interface
  17. * methods as required.
  18. */
  19. struct xfer_filter_half {
  20. /** Data transfer interface */
  21. struct xfer_interface xfer;
  22. /** Other half of the data transfer filter */
  23. struct xfer_filter_half *other;
  24. };
  25. /**
  26. * Get data transfer interface for the other half of a data transfer filter
  27. *
  28. * @v xfer Data transfer interface
  29. * @ret other Other half's data transfer interface
  30. */
  31. static inline __attribute__ (( always_inline )) struct xfer_interface *
  32. filter_other_half ( struct xfer_interface *xfer ) {
  33. struct xfer_filter_half *half =
  34. container_of ( xfer, struct xfer_filter_half, xfer );
  35. return &half->other->xfer;
  36. }
  37. extern void filter_close ( struct xfer_interface *xfer, int rc );
  38. extern int filter_vredirect ( struct xfer_interface *xfer, int type,
  39. va_list args );
  40. extern size_t filter_window ( struct xfer_interface *xfer );
  41. extern struct io_buffer * filter_alloc_iob ( struct xfer_interface *xfer,
  42. size_t len );
  43. extern int filter_deliver_iob ( struct xfer_interface *xfer,
  44. struct io_buffer *iobuf,
  45. struct xfer_metadata *meta );
  46. extern int filter_deliver_raw ( struct xfer_interface *xfer, const void *data,
  47. size_t len );
  48. /**
  49. * Initialise a data transfer filter
  50. *
  51. * @v left "Left" half of the filter
  52. * @v left_op Data transfer interface operations for "left" half
  53. * @v right "Right" half of the filter
  54. * @v right_op Data transfer interface operations for "right" half
  55. * @v refcnt Containing object reference counter, or NULL
  56. */
  57. static inline void filter_init ( struct xfer_filter_half *left,
  58. struct xfer_interface_operations *left_op,
  59. struct xfer_filter_half *right,
  60. struct xfer_interface_operations *right_op,
  61. struct refcnt *refcnt ) {
  62. xfer_init ( &left->xfer, left_op, refcnt );
  63. xfer_init ( &right->xfer, right_op, refcnt );
  64. left->other = right;
  65. right->other = left;
  66. }
  67. #endif /* _GPXE_FILTER_H */