mirror of
https://github.com/xcat2/xNBA.git
synced 2024-12-16 00:01:34 +00:00
Add insert_filter() function
This commit is contained in:
parent
a008f9e85b
commit
e38e516463
@ -41,4 +41,7 @@ extern int filter_send ( struct stream_connection *conn,
|
||||
void *data, size_t len );
|
||||
extern int filter_kick ( struct stream_connection *conn );
|
||||
|
||||
extern int insert_filter ( struct stream_application *app,
|
||||
struct filter_stream *filter );
|
||||
|
||||
#endif /* _GPXE_FILTER_H */
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include <gpxe/stream.h>
|
||||
#include <gpxe/filter.h>
|
||||
|
||||
@ -161,3 +162,26 @@ int filter_kick ( struct stream_connection *conn ) {
|
||||
|
||||
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
Block a user