mirror of https://github.com/ipxe/ipxe.git
Add insert_filter() function
parent
a008f9e85b
commit
e38e516463
|
@ -41,4 +41,7 @@ extern int filter_send ( struct stream_connection *conn,
|
||||||
void *data, size_t len );
|
void *data, size_t len );
|
||||||
extern int filter_kick ( struct stream_connection *conn );
|
extern int filter_kick ( struct stream_connection *conn );
|
||||||
|
|
||||||
|
extern int insert_filter ( struct stream_application *app,
|
||||||
|
struct filter_stream *filter );
|
||||||
|
|
||||||
#endif /* _GPXE_FILTER_H */
|
#endif /* _GPXE_FILTER_H */
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <gpxe/stream.h>
|
#include <gpxe/stream.h>
|
||||||
#include <gpxe/filter.h>
|
#include <gpxe/filter.h>
|
||||||
|
|
||||||
|
@ -161,3 +162,26 @@ int filter_kick ( struct stream_connection *conn ) {
|
||||||
|
|
||||||
return stream_kick ( &filter->downstream );
|
return stream_kick ( &filter->downstream );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert filter into stream
|
||||||
|
*
|
||||||
|
* @v app Stream application
|
||||||
|
* @v filter Filter stream
|
||||||
|
* @ret rc Return status code
|
||||||
|
*/
|
||||||
|
int insert_filter ( struct stream_application *app,
|
||||||
|
struct filter_stream *filter ) {
|
||||||
|
struct stream_connection *conn = app->conn;
|
||||||
|
|
||||||
|
if ( ! app->conn ) {
|
||||||
|
DBGC ( filter, "Filter %p cannot insert onto closed stream\n",
|
||||||
|
filter );
|
||||||
|
return -ENOTCONN;
|
||||||
|
}
|
||||||
|
|
||||||
|
app->conn = &filter->upstream;
|
||||||
|
conn->app = &filter->downstream;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue