Browse Source

Add insert_filter() function

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
e38e516463
2 changed files with 27 additions and 0 deletions
  1. 3
    0
      src/include/gpxe/filter.h
  2. 24
    0
      src/net/filter.c

+ 3
- 0
src/include/gpxe/filter.h View File

@@ -41,4 +41,7 @@ extern int filter_send ( struct stream_connection *conn,
41 41
 			 void *data, size_t len );
42 42
 extern int filter_kick ( struct stream_connection *conn );
43 43
 
44
+extern int insert_filter ( struct stream_application *app,
45
+			   struct filter_stream *filter );
46
+
44 47
 #endif /* _GPXE_FILTER_H */

+ 24
- 0
src/net/filter.c View File

@@ -23,6 +23,7 @@
23 23
  */
24 24
 
25 25
 #include <stddef.h>
26
+#include <errno.h>
26 27
 #include <gpxe/stream.h>
27 28
 #include <gpxe/filter.h>
28 29
 
@@ -161,3 +162,26 @@ int filter_kick ( struct stream_connection *conn ) {
161 162
 
162 163
 	return stream_kick ( &filter->downstream );
163 164
 }
165
+
166
+/**
167
+ * Insert filter into stream
168
+ *
169
+ * @v app		Stream application
170
+ * @v filter		Filter stream
171
+ * @ret rc		Return status code
172
+ */
173
+int insert_filter ( struct stream_application *app,
174
+		    struct filter_stream *filter ) {
175
+	struct stream_connection *conn = app->conn;
176
+
177
+	if ( ! app->conn ) {
178
+		DBGC ( filter, "Filter %p cannot insert onto closed stream\n",
179
+		       filter );
180
+		return -ENOTCONN;
181
+	}
182
+
183
+	app->conn = &filter->upstream;
184
+	conn->app = &filter->downstream;
185
+
186
+	return 0;
187
+}

Loading…
Cancel
Save