summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2007-01-31 04:04:56 +0100
committerMichael Brown2007-01-31 04:04:56 +0100
commite38e516463cf1e551cca6394bc5cb6cc90821105 (patch)
treebcb8ca301f88eeaa871bfc0c1c72ed6b246e59a1 /src
parentAdd null crypto algorithm (diff)
downloadipxe-e38e516463cf1e551cca6394bc5cb6cc90821105.tar.gz
ipxe-e38e516463cf1e551cca6394bc5cb6cc90821105.tar.xz
ipxe-e38e516463cf1e551cca6394bc5cb6cc90821105.zip
Add insert_filter() function
Diffstat (limited to 'src')
-rw-r--r--src/include/gpxe/filter.h3
-rw-r--r--src/net/filter.c24
2 files changed, 27 insertions, 0 deletions
diff --git a/src/include/gpxe/filter.h b/src/include/gpxe/filter.h
index 585bbe15d..96c39e0de 100644
--- a/src/include/gpxe/filter.h
+++ b/src/include/gpxe/filter.h
@@ -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 */
diff --git a/src/net/filter.c b/src/net/filter.c
index 7d93c61c1..c4542fcbf 100644
--- a/src/net/filter.c
+++ b/src/net/filter.c
@@ -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;
+}