Add insert_filter() function
authorMichael Brown <mcb30@etherboot.org>
Wed, 31 Jan 2007 03:04:56 +0000 (03:04 +0000)
committerMichael Brown <mcb30@etherboot.org>
Wed, 31 Jan 2007 03:04:56 +0000 (03:04 +0000)
src/include/gpxe/filter.h
src/net/filter.c

index 585bbe1..96c39e0 100644 (file)
@@ -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 );
 
                         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 */
 #endif /* _GPXE_FILTER_H */
index 7d93c61..c4542fc 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <stddef.h>
  */
 
 #include <stddef.h>
+#include <errno.h>
 #include <gpxe/stream.h>
 #include <gpxe/filter.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 );
 }
 
        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;
+}