Procházet zdrojové kódy

Remove some obsolete stream-API files

tags/v0.9.3
Michael Brown před 17 roky
rodič
revize
9dc6a1e678
5 změnil soubory, kde provedl 0 přidání a 781 odebrání
  1. 0
    47
      src/include/gpxe/filter.h
  2. 0
    190
      src/include/gpxe/stream.h
  3. 0
    1
      src/include/gpxe/tcp.h
  4. 0
    191
      src/net/filter.c
  5. 0
    352
      src/net/stream.c

+ 0
- 47
src/include/gpxe/filter.h Zobrazit soubor

@@ -1,47 +0,0 @@
1
-#ifndef _GPXE_FILTER_H
2
-#define _GPXE_FILTER_H
3
-
4
-/** @file
5
- *
6
- * Filter streams
7
- */
8
-
9
-#include <gpxe/stream.h>
10
-
11
-/** A filter stream */
12
-struct filter_stream {
13
-	/** Downstream
14
-	 *
15
-	 * This is the end pointing towards the bottom-level
16
-	 * connection (e.g. TCP).
17
-	 */
18
-	struct stream_application downstream;
19
-	/** Upstream
20
-	 *
21
-	 * This is the end pointing towards the top-level application
22
-	 * (e.g. HTTP).
23
-	 */
24
-	struct stream_connection upstream;
25
-};
26
-
27
-extern void filter_connected ( struct stream_application *app );
28
-extern void filter_closed ( struct stream_application *app, int rc );
29
-extern void filter_senddata ( struct stream_application *app,
30
-			      void *data, size_t len );
31
-extern void filter_acked ( struct stream_application *app, size_t len );
32
-extern void filter_newdata ( struct stream_application *app,
33
-			     void *data, size_t len );
34
-
35
-extern int filter_bind ( struct stream_connection *conn,
36
-			 struct sockaddr *local );
37
-extern int filter_connect ( struct stream_connection *conn,
38
-			    struct sockaddr *peer );
39
-extern void filter_close ( struct stream_connection *conn );
40
-extern int filter_send ( struct stream_connection *conn,
41
-			 void *data, size_t len );
42
-extern int filter_kick ( struct stream_connection *conn );
43
-
44
-extern int insert_filter ( struct stream_application *app,
45
-			   struct filter_stream *filter );
46
-
47
-#endif /* _GPXE_FILTER_H */

+ 0
- 190
src/include/gpxe/stream.h Zobrazit soubor

@@ -1,190 +0,0 @@
1
-#ifndef _GPXE_STREAM_H
2
-#define _GPXE_STREAM_H
3
-
4
-/** @file
5
- *
6
- * Stream API
7
- */
8
-
9
-#include <stdint.h>
10
-#include <gpxe/socket.h>
11
-
12
-struct stream_application;
13
-struct stream_connection;
14
-
15
-/** Stream applicatin-layer operations */
16
-struct stream_application_operations {
17
-	/**
18
-	 * Connection established
19
-	 *
20
-	 * @v app		Stream application
21
-	 */
22
-	void ( * connected ) ( struct stream_application *app );
23
-	/**
24
-	 * Connection closed
25
-	 *
26
-	 * @v app		Stream application
27
-	 * @v rc		Error code, if any
28
-	 *
29
-	 * This is called when the connection is closed for any
30
-	 * reason, including timeouts or aborts.  The error code
31
-	 * contains the negative error number, if the closure is due
32
-	 * to an error, or zero for a normal close.
33
-	 *
34
-	 * When closed() is called, the application no longer has a
35
-	 * valid stream connection.  Note that connected() may not
36
-	 * have been called before closed(), if the close is due to an
37
-	 * error during connection setup.
38
-	 */
39
-	void ( * closed ) ( struct stream_application *app, int rc );
40
-	/**
41
-	 * Transmit data
42
-	 *
43
-	 * @v app		Stream application
44
-	 * @v data		Temporary data buffer
45
-	 * @v len		Length of temporary data buffer
46
-	 *
47
-	 * The application should transmit whatever it currently wants
48
-	 * to send using stream_send().  If retransmissions are
49
-	 * required, senddata() will be called again and the
50
-	 * application must regenerate the data.  The easiest way to
51
-	 * implement this is to ensure that senddata() never changes
52
-	 * the application's state.
53
-	 *
54
-	 * The application may use the temporary data buffer to
55
-	 * construct the data to be sent.  Note that merely filling
56
-	 * the buffer will do nothing; the application must call
57
-	 * stream_send() in order to actually transmit the data.  Use
58
-	 * of the buffer is not compulsory; the application may call
59
-	 * stream_send() on any block of data.
60
-	 */
61
-	void ( * senddata ) ( struct stream_application *app,
62
-			      void *data, size_t len );
63
-	/**
64
-	 * Transmitted data acknowledged
65
-	 *
66
-	 * @v app		Stream application
67
-	 * @v len		Length of acknowledged data
68
-	 *
69
-	 * @c len is guaranteed to not exceed the outstanding amount
70
-	 * of unacknowledged data.
71
-	 */
72
-	void ( * acked ) ( struct stream_application *app, size_t len );
73
-	/**
74
-	 * Receive new data
75
-	 *
76
-	 * @v app		Stream application
77
-	 * @v data		Data
78
-	 * @v len		Length of data
79
-	 */
80
-	void ( * newdata ) ( struct stream_application *app,
81
-			     void *data, size_t len );
82
-};
83
-
84
-/** Stream connection-layer operations */
85
-struct stream_connection_operations {
86
-	/**
87
-	 * Bind to local address
88
-	 *
89
-	 * @v conn		Stream connection
90
-	 * @v local		Local address
91
-	 * @ret rc		Return status code
92
-	 */
93
-	int ( * bind ) ( struct stream_connection *conn,
94
-			 struct sockaddr *local );
95
-	/**
96
-	 * Connect to remote address
97
-	 *
98
-	 * @v conn		Stream connection
99
-	 * @v peer		Remote address
100
-	 * @ret rc		Return status code
101
-	 *
102
-	 * This initiates the connection.  If the connection succeeds,
103
-	 * the application's connected() method will be called.  If
104
-	 * the connection fails (e.g. due to a timeout), the
105
-	 * application's closed() method will be called with an
106
-	 * appropriate error code.
107
-	 */
108
-	int ( * connect ) ( struct stream_connection *conn,
109
-			    struct sockaddr *peer );
110
-	/**
111
-	 * Close connection
112
-	 *
113
-	 * @v conn		Stream connection
114
-	 */
115
-	void ( * close ) ( struct stream_connection *conn );
116
-	/**
117
-	 * Send data via connection
118
-	 *
119
-	 * @v conn		Stream connection
120
-	 * @v data		Data to send
121
-	 * @v len		Length of data
122
-	 * @ret rc		Return status code
123
-	 *
124
-	 * This method should be called only in the context of an
125
-	 * application's senddata() method.
126
-	 */
127
-	int ( * send ) ( struct stream_connection *conn,
128
-			 const void *data, size_t len );
129
-	/**
130
-	 * Notify connection that data is available to send
131
-	 *
132
-	 * @v conn		Stream connection
133
-	 * @ret rc		Return status code
134
-	 *
135
-	 * This will cause the connection to call the application's
136
-	 * senddata() method.  It should be called when the
137
-	 * application acquires new data to send as a result of
138
-	 * something external to the data stream (e.g. when iSCSI is
139
-	 * asked to issue a new command on an otherwise-idle
140
-	 * connection).  Most applications will not need to call this
141
-	 * method.
142
-	 */
143
-	int ( * kick ) ( struct stream_connection *conn );
144
-};
145
-
146
-/** A stream application */
147
-struct stream_application {
148
-	/** Stream connection, if any
149
-	 *
150
-	 * This will be NULL if the stream does not currently have a
151
-	 * valid connection.
152
-	 */
153
-	struct stream_connection *conn;
154
-	/** Stream application-layer operations */
155
-	struct stream_application_operations *op;
156
-};
157
-
158
-/** A stream connection */
159
-struct stream_connection {
160
-	/** Stream application, if any
161
-	 *
162
-	 * This will be NULL if the stream does not currently have a
163
-	 * valid application.
164
-	 */
165
-	struct stream_application *app;
166
-	/** Stream connection-layer operations */
167
-	struct stream_connection_operations *op;	
168
-};
169
-
170
-extern void stream_associate ( struct stream_application *app,
171
-			       struct stream_connection *conn );
172
-
173
-extern void stream_connected ( struct stream_connection *conn );
174
-extern void stream_closed ( struct stream_connection *conn, int rc );
175
-extern void stream_senddata ( struct stream_connection *conn,
176
-			      void *data, size_t len );
177
-extern void stream_acked ( struct stream_connection *conn, size_t len );
178
-extern void stream_newdata ( struct stream_connection *conn,
179
-			     void *data, size_t len );
180
-
181
-extern int stream_bind ( struct stream_application *app,
182
-			 struct sockaddr *local );
183
-extern int stream_connect ( struct stream_application *app,
184
-			    struct sockaddr *peer );
185
-extern void stream_close ( struct stream_application *app );
186
-extern int stream_send ( struct stream_application *app,
187
-			 const void *data, size_t len );
188
-extern int stream_kick ( struct stream_application *app );
189
-
190
-#endif /* _GPXE_STREAM_H */

+ 0
- 1
src/include/gpxe/tcp.h Zobrazit soubor

@@ -11,7 +11,6 @@
11 11
 
12 12
 #include "latch.h"
13 13
 #include <gpxe/tcpip.h>
14
-#include <gpxe/stream.h>
15 14
 
16 15
 /**
17 16
  * A TCP header

+ 0
- 191
src/net/filter.c Zobrazit soubor

@@ -1,191 +0,0 @@
1
-/*
2
- * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License as
6
- * published by the Free Software Foundation; either version 2 of the
7
- * License, or any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful, but
10
- * WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, write to the Free Software
16
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
- */
18
-
19
-/**
20
- * @file
21
- *
22
- * Filter streams
23
- */
24
-
25
-#include <stddef.h>
26
-#include <errno.h>
27
-#include <gpxe/stream.h>
28
-#include <gpxe/filter.h>
29
-
30
-/**
31
- * Connection established
32
- *
33
- * @v app		Stream application
34
- */
35
-void filter_connected ( struct stream_application *app ) {
36
-	struct filter_stream *filter = 
37
-		container_of ( app, struct filter_stream, downstream );
38
-
39
-	stream_connected ( &filter->upstream );
40
-}
41
-
42
-/**
43
- * Connection closed
44
- *
45
- * @v app		Stream application
46
- * @v rc		Error code, if any
47
- */
48
-void filter_closed ( struct stream_application *app, int rc ) {
49
-	struct filter_stream *filter = 
50
-		container_of ( app, struct filter_stream, downstream );
51
-
52
-	stream_closed ( &filter->upstream, rc );
53
-}
54
-
55
-/**
56
- * Transmit data
57
- *
58
- * @v app		Stream application
59
- * @v buf		Temporary data buffer
60
- * @v len		Length of temporary data buffer
61
- */
62
-void filter_senddata ( struct stream_application *app,
63
-		       void *data, size_t len ) {
64
-	struct filter_stream *filter = 
65
-		container_of ( app, struct filter_stream, downstream );
66
-
67
-	stream_senddata ( &filter->upstream, data, len );
68
-}
69
-
70
-/**
71
- * Transmitted data acknowledged
72
- *
73
- * @v app		Stream application
74
- * @v len		Length of acknowledged data
75
- */
76
-void filter_acked ( struct stream_application *app, size_t len ) {
77
-	struct filter_stream *filter = 
78
-		container_of ( app, struct filter_stream, downstream );
79
-
80
-	stream_acked ( &filter->upstream, len );
81
-}
82
-
83
-/**
84
- * Receive new data
85
- *
86
- * @v app		Stream application
87
- * @v data		Data
88
- * @v len		Length of data
89
- */
90
-void filter_newdata ( struct stream_application *app,
91
-		      void *data, size_t len ) {
92
-	struct filter_stream *filter = 
93
-		container_of ( app, struct filter_stream, downstream );
94
-
95
-	stream_newdata ( &filter->upstream, data, len );
96
-}
97
-
98
-/**
99
- * Bind to local address
100
- *
101
- * @v conn		Stream connection
102
- * @v local		Local address
103
- * @ret rc		Return status code
104
- */
105
-int filter_bind ( struct stream_connection *conn, struct sockaddr *local ) {
106
-	struct filter_stream *filter = 
107
-		container_of ( conn, struct filter_stream, upstream );
108
-
109
-	return stream_bind ( &filter->downstream, local );
110
-}
111
-
112
-/**
113
- * Connect to remote address
114
- *
115
- * @v conn		Stream connection
116
- * @v peer		Remote address
117
- * @ret rc		Return status code
118
- */
119
-int filter_connect ( struct stream_connection *conn, struct sockaddr *peer ) {
120
-	struct filter_stream *filter = 
121
-		container_of ( conn, struct filter_stream, upstream );
122
-
123
-	return stream_connect ( &filter->downstream, peer );
124
-}
125
-
126
-/**
127
- * Close connection
128
- *
129
- * @v conn		Stream connection
130
- */
131
-void filter_close ( struct stream_connection *conn ) {
132
-	struct filter_stream *filter = 
133
-		container_of ( conn, struct filter_stream, upstream );
134
-
135
-	stream_close ( &filter->downstream );
136
-}
137
-
138
-/**
139
- * Send data via connection
140
- *
141
- * @v conn		Stream connection
142
- * @v data		Data to send
143
- * @v len		Length of data
144
- * @ret rc		Return status code
145
- */
146
-int filter_send ( struct stream_connection *conn, void *data, size_t len ) {
147
-	struct filter_stream *filter = 
148
-		container_of ( conn, struct filter_stream, upstream );
149
-
150
-	return stream_send ( &filter->downstream, data, len );
151
-}
152
-
153
-/**
154
- * Notify connection that data is available to send
155
- *
156
- * @v conn		Stream connection
157
- * @ret rc		Return status code
158
- */
159
-int filter_kick ( struct stream_connection *conn ) {
160
-	struct filter_stream *filter = 
161
-		container_of ( conn, struct filter_stream, upstream );
162
-
163
-	return stream_kick ( &filter->downstream );
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 ( ! conn ) {
178
-		DBGC ( filter, "Filter %p cannot insert onto closed stream\n",
179
-		       filter );
180
-		return -ENOTCONN;
181
-	}
182
-
183
-	DBGC ( filter, "Filter %p inserted on stream %p\n", filter, app );
184
-
185
-	filter->upstream.app = app;
186
-	filter->downstream.conn = conn;
187
-	app->conn = &filter->upstream;
188
-	conn->app = &filter->downstream;
189
-
190
-	return 0;
191
-}

+ 0
- 352
src/net/stream.c Zobrazit soubor

@@ -1,352 +0,0 @@
1
-/*
2
- * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License as
6
- * published by the Free Software Foundation; either version 2 of the
7
- * License, or any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful, but
10
- * WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, write to the Free Software
16
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
- */
18
-
19
-/**
20
- * @file
21
- *
22
- * Stream API
23
- */
24
-
25
-#include <stdint.h>
26
-#include <string.h>
27
-#include <errno.h>
28
-#include <assert.h>
29
-#include <gpxe/stream.h>
30
-
31
-/**
32
- * Associate application with connection
33
- *
34
- * @v app		Stream application
35
- * @v conn		Stream connection
36
- */
37
-void stream_associate ( struct stream_application *app,
38
-			struct stream_connection *conn ) {
39
-
40
-	DBGC ( app, "Stream %p associating with connection %p\n", app, conn );
41
-
42
-	assert ( conn->app == NULL );
43
-	assert ( app->conn == NULL );
44
-	conn->app = app;
45
-	app->conn = conn;
46
-}
47
-
48
-/**
49
- * Disassociate application from connection
50
- *
51
- * @v app		Stream application
52
- * @v conn		Stream connection
53
- */
54
-static void stream_disassociate ( struct stream_application *app,
55
-				  struct stream_connection *conn ) {
56
-
57
-	DBGC ( app, "Stream %p disassociating from connection %p\n",
58
-	       app, conn );
59
-
60
-	assert ( conn->app == app );
61
-	assert ( app->conn == conn );
62
-	conn->app = NULL;
63
-	app->conn = NULL;	
64
-}
65
-
66
-/**
67
- * Connection established
68
- *
69
- * @v conn		Stream connection
70
- */
71
-void stream_connected ( struct stream_connection *conn ) {
72
-	struct stream_application *app = conn->app;
73
-
74
-	DBGC ( app, "Stream %p connected\n", app );
75
-
76
-	/* Check connection actually exists */
77
-	if ( ! app ) {
78
-		DBGC ( conn, "Stream connection %p has no application\n",
79
-		       conn );
80
-		return;
81
-	}
82
-
83
-	/* Hand off to application */
84
-	if ( app->op->connected )
85
-		app->op->connected ( app );
86
-}
87
-
88
-/**
89
- * Connection closed
90
- *
91
- * @v conn		Stream connection
92
- * @v rc		Error code, if any
93
- */
94
-void stream_closed ( struct stream_connection *conn, int rc ) {
95
-	struct stream_application *app = conn->app;
96
-
97
-	/* Check connection actually exists */
98
-	if ( ! app ) {
99
-		/* Not an error; don't display a debug message */
100
-		return;
101
-	}
102
-
103
-	DBGC ( app, "Stream %p closed (%s)\n", app, strerror ( rc ) );
104
-
105
-	/* Disassociate application from connection */
106
-	stream_disassociate ( app, conn );
107
-
108
-	/* Hand off to application */
109
-	if ( app->op->closed )
110
-		app->op->closed ( app, rc );
111
-}
112
-
113
-/**
114
- * Transmit data
115
- *
116
- * @v conn		Stream connection
117
- * @v data		Temporary data buffer
118
- * @v len		Length of temporary data buffer
119
- */
120
-void stream_senddata ( struct stream_connection *conn,
121
-		       void *data, size_t len ) {
122
-	struct stream_application *app = conn->app;
123
-
124
-	DBGC2 ( app, "Stream %p sending data\n", app );
125
-
126
-	/* Check connection actually exists */
127
-	if ( ! app ) {
128
-		DBGC ( conn, "Stream connection %p has no application\n",
129
-		       conn );
130
-		return;
131
-	}
132
-
133
-	/* Hand off to application */
134
-	if ( app->op->senddata )
135
-		app->op->senddata ( app, data, len );
136
-}
137
-
138
-/**
139
- * Transmitted data acknowledged
140
- *
141
- * @v conn		Stream connection
142
- * @v len		Length of acknowledged data
143
- *
144
- * @c len must not exceed the outstanding amount of unacknowledged
145
- * data.
146
- */
147
-void stream_acked ( struct stream_connection *conn, size_t len ) {
148
-	struct stream_application *app = conn->app;
149
-
150
-	DBGC2 ( app, "Stream %p had %zd bytes acknowledged\n", app, len );
151
-
152
-	/* Check connection actually exists */
153
-	if ( ! app ) {
154
-		DBGC ( conn, "Stream connection %p has no application\n",
155
-		       conn );
156
-		return;
157
-	}
158
-
159
-	/* Ignore zero-length blocks */
160
-	if ( len == 0 )
161
-		return;
162
-
163
-	/* Hand off to application */
164
-	if ( app->op->acked )
165
-		app->op->acked ( app, len );
166
-}
167
-
168
-/**
169
- * Receive new data
170
- *
171
- * @v conn		Stream connection
172
- * @v data		Data
173
- * @v len		Length of data
174
- */
175
-void stream_newdata ( struct stream_connection *conn, 
176
-		      void *data, size_t len ) {
177
-	struct stream_application *app = conn->app;
178
-
179
-	DBGC2 ( app, "Stream %p received %zd bytes\n", app, len );
180
-
181
-	/* Check connection actually exists */
182
-	if ( ! app ) {
183
-		DBGC ( conn, "Stream connection %p has no application\n",
184
-		       conn );
185
-		return;
186
-	}
187
-
188
-	/* Ignore zero-length blocks */
189
-	if ( len == 0 )
190
-		return;
191
-
192
-	/* Hand off to application */
193
-	if ( app->op->newdata )
194
-		app->op->newdata ( app, data, len );
195
-}
196
-
197
-/**
198
- * Bind to local address
199
- *
200
- * @v app		Stream application
201
- * @v local		Local address
202
- * @ret rc		Return status code
203
- */
204
-int stream_bind ( struct stream_application *app, struct sockaddr *local ) {
205
-	struct stream_connection *conn = app->conn;
206
-	int rc;
207
-
208
-	DBGC2 ( app, "Stream %p binding\n", app );
209
-
210
-	/* Check connection actually exists */
211
-	if ( ! conn ) {
212
-		DBGC ( app, "Stream %p has no connection\n", app );
213
-		return -ENOTCONN;
214
-	}
215
-
216
-	/* Hand off to connection */
217
-	if ( ! conn->op->bind )
218
-		return -ENOTSUP;
219
-	if ( ( rc = conn->op->bind ( conn, local ) ) != 0 ) {
220
-		DBGC ( app, "Stream %p failed to bind: %s\n",
221
-		       app, strerror ( rc ) );
222
-		return rc;
223
-	}
224
-
225
-	return 0;
226
-}
227
-
228
-/**
229
- * Connect to remote address
230
- *
231
- * @v app		Stream application
232
- * @v peer		Remote address
233
- * @ret rc		Return status code
234
- */
235
-int stream_connect ( struct stream_application *app, struct sockaddr *peer ) {
236
-	struct stream_connection *conn = app->conn;
237
-	int rc;
238
-
239
-	DBGC2 ( app, "Stream %p connecting\n", app );
240
-
241
-	/* Check connection actually exists */
242
-	if ( ! conn ) {
243
-		DBGC ( app, "Stream %p has no connection\n", app );
244
-		return -ENOTCONN;
245
-	}
246
-
247
-	/* Hand off to connection */
248
-	if ( ! conn->op->connect )
249
-		return -ENOTSUP;
250
-	if ( ( rc = conn->op->connect ( conn, peer ) ) != 0 ) {
251
-		DBGC ( app, "Stream %p failed to connect: %s\n",
252
-		       app, strerror ( rc ) );
253
-		return rc;
254
-	}
255
-
256
-	return 0;
257
-}
258
-
259
-/**
260
- * Close connection
261
- *
262
- * @v app		Stream application
263
- */
264
-void stream_close ( struct stream_application *app ) {
265
-	struct stream_connection *conn = app->conn;
266
-
267
-	DBGC2 ( app, "Stream %p closing\n", app );
268
-
269
-	/* Check connection actually exists */
270
-	if ( ! conn ) {
271
-		/* Not an error; don't display a debug message */
272
-		return;
273
-	}
274
-
275
-	/* Disassociate application from connection */
276
-	stream_disassociate ( app, conn );
277
-
278
-	/* Hand off to connection */
279
-	if ( ! conn->op->close )
280
-		return;
281
-	conn->op->close ( conn );
282
-}
283
-
284
-/**
285
- * Send data via connection
286
- *
287
- * @v app		Stream application
288
- * @v data		Data to send
289
- * @v len		Length of data
290
- * @ret rc		Return status code
291
- *
292
- * This method should be called only in the context of an
293
- * application's senddata() method.
294
- */
295
-int stream_send ( struct stream_application *app,
296
-		  const void *data, size_t len ) {
297
-	struct stream_connection *conn = app->conn;
298
-	int rc;
299
-
300
-	DBGC2 ( app, "Stream %p sending %zd bytes\n", app, len );
301
-
302
-	/* Check connection actually exists */
303
-	if ( ! conn ) {
304
-		DBGC ( app, "Stream %p has no connection\n", app );
305
-		return -ENOTCONN;
306
-	}
307
-
308
-	/* Ignore zero-length blocks */
309
-	if ( len == 0 )
310
-		return 0;
311
-
312
-	/* Hand off to connection */
313
-	if ( ! conn->op->send )
314
-		return -ENOTSUP;
315
-	if ( ( rc = conn->op->send ( conn, data, len ) ) != 0 ) {
316
-		DBGC ( app, "Stream %p failed to send %zd bytes: %s\n",
317
-		       app, len, strerror ( rc ) );
318
-		return rc;
319
-	}
320
-
321
-	return 0;
322
-}
323
-
324
-/**
325
- * Notify connection that data is available to send
326
- *
327
- * @v app		Stream application
328
- * @ret rc		Return status code
329
- */
330
-int stream_kick ( struct stream_application *app ) {
331
-		struct stream_connection *conn = app->conn;
332
-	int rc;
333
-
334
-	DBGC2 ( app, "Stream %p kicking connection\n", app );
335
-
336
-	/* Check connection actually exists */
337
-	if ( ! conn ) {
338
-		DBGC ( app, "Stream %p has no connection\n", app );
339
-		return -ENOTCONN;
340
-	}
341
-
342
-	/* Hand off to connection */
343
-	if ( ! conn->op->send )
344
-		return -ENOTSUP;
345
-	if ( ( rc = conn->op->kick ( conn ) ) != 0 ) {
346
-		DBGC ( app, "Stream %p failed to kick connection: %s\n",
347
-		       app, strerror ( rc ) );
348
-		return rc;
349
-	}
350
-
351
-	return 0;
352
-}

Načítá se…
Zrušit
Uložit