Changed to use the generic stream API.

This commit is contained in:
Michael Brown
2007-01-31 02:09:13 +00:00
parent 02f18565da
commit 6d32f0e6e2
10 changed files with 500 additions and 541 deletions

View File

@@ -9,7 +9,7 @@
#include <stdint.h>
#include <gpxe/async.h>
#include <gpxe/tcp.h>
#include <gpxe/stream.h>
struct buffer;
@@ -57,10 +57,10 @@ struct ftp_request {
char status_text[4];
/** Passive-mode parameters, as text */
char passive_text[24]; /* "aaa,bbb,ccc,ddd,eee,fff" */
/** TCP application for the control channel */
struct tcp_application tcp;
/** TCP application for the data channel */
struct tcp_application tcp_data;
/** Stream application for the control channel */
struct stream_application stream;
/** Stream application for the data channel */
struct stream_application stream_data;
};
extern int ftp_get ( struct uri *uri, struct buffer *buffer,

View File

@@ -8,7 +8,7 @@
*/
#include <stdint.h>
#include <gpxe/tcp.h>
#include <gpxe/stream.h>
#include <gpxe/async.h>
#include <gpxe/linebuf.h>
#include <gpxe/uri.h>
@@ -43,8 +43,8 @@ struct http_request {
/** Server address */
struct sockaddr server;
/** TCP application for this request */
struct tcp_application tcp;
/** Stream application for this request */
struct stream_application stream;
/** Number of bytes already sent */
size_t tx_offset;
/** RX state */

View File

@@ -8,7 +8,7 @@
*/
#include <stdint.h>
#include <gpxe/tcp.h>
#include <gpxe/stream.h>
#include <gpxe/async.h>
#include <gpxe/scsi.h>
#include <gpxe/chap.h>
@@ -489,7 +489,7 @@ struct iscsi_session {
/** Initiator IQN */
const char *initiator_iqn;
/** Target address */
struct sockaddr_tcpip target;
struct sockaddr target;
/** Target IQN */
const char *target_iqn;
/** Logical Unit Number (LUN) */
@@ -499,8 +499,8 @@ struct iscsi_session {
/** Password */
const char *password;
/** TCP application for this session */
struct tcp_application tcp;
/** Stream application for this session */
struct stream_application stream;
/** Session status
*
* This is the bitwise-OR of zero or more ISCSI_STATUS_XXX

View File

@@ -125,7 +125,7 @@ struct stream_connection_operations {
* application's senddata() method.
*/
int ( * send ) ( struct stream_connection *conn,
void *data, size_t len );
const void *data, size_t len );
/**
* Notify connection that data is available to send
*
@@ -167,6 +167,9 @@ struct stream_connection {
struct stream_connection_operations *op;
};
extern void stream_associate ( struct stream_application *app,
struct stream_connection *conn );
extern void stream_connected ( struct stream_connection *conn );
extern void stream_closed ( struct stream_connection *conn, int rc );
extern void stream_senddata ( struct stream_connection *conn,
@@ -181,7 +184,7 @@ extern int stream_connect ( struct stream_application *app,
struct sockaddr *peer );
extern void stream_close ( struct stream_application *app );
extern int stream_send ( struct stream_application *app,
void *data, size_t len );
const void *data, size_t len );
extern int stream_kick ( struct stream_application *app );
#endif /* _GPXE_STREAM_H */

View File

@@ -11,6 +11,7 @@
#include "latch.h"
#include <gpxe/tcpip.h>
#include <gpxe/stream.h>
/**
* A TCP header
@@ -252,105 +253,7 @@ struct tcp_mss_option {
*/
#define TCP_MSL ( 2 * 60 * TICKS_PER_SEC )
struct tcp_application;
/**
* TCP operations
*
*/
struct tcp_operations {
/*
* Connection closed
*
* @v app TCP application
* @v status Error code, if any
*
* This is called when the connection is closed for any
* reason, including timeouts or aborts. The status code
* contains the negative error number, if the closure is due
* to an error.
*
* When closed() is called, the application no longer has a
* valid TCP connection. Note that connected() may not have
* been called before closed(), if the close is due to an
* error during connection setup.
*/
void ( * closed ) ( struct tcp_application *app, int status );
/**
* Connection established
*
* @v app TCP application
*/
void ( * connected ) ( struct tcp_application *app );
/**
* Data acknowledged
*
* @v app TCP application
* @v len Length of acknowledged data
*
* @c len is guaranteed to not exceed the outstanding amount
* of unacknowledged data.
*/
void ( * acked ) ( struct tcp_application *app, size_t len );
/**
* New data received
*
* @v app TCP application
* @v data Data
* @v len Length of data
*/
void ( * newdata ) ( struct tcp_application *app,
void *data, size_t len );
/**
* Transmit data
*
* @v app TCP application
* @v buf Temporary data buffer
* @v len Length of temporary data buffer
*
* The application should transmit whatever it currently wants
* to send using tcp_send(). If retransmissions are required,
* senddata() will be called again and the application must
* regenerate the data. The easiest way to implement this is
* to ensure that senddata() never changes the application's
* state.
*
* The application may use the temporary data buffer to
* construct the data to be sent. Note that merely filling
* the buffer will do nothing; the application must call
* tcp_send() in order to actually transmit the data. Use of
* the buffer is not compulsory; the application may call
* tcp_send() on any block of data.
*/
void ( * senddata ) ( struct tcp_application *app, void *buf,
size_t len );
};
struct tcp_connection;
/**
* A TCP application
*
* This data structure represents an application with a TCP connection.
*/
struct tcp_application {
/** TCP connection data
*
* This is filled in by TCP calls that initiate a connection,
* and reset to NULL when the connection is closed.
*/
struct tcp_connection *conn;
/** TCP connection operations table */
struct tcp_operations *tcp_op;
};
extern int tcp_connect ( struct tcp_application *app,
struct sockaddr_tcpip *peer,
uint16_t local_port );
extern void tcp_close ( struct tcp_application *app );
extern int tcp_senddata ( struct tcp_application *app );
extern int tcp_send ( struct tcp_application *app, const void *data,
size_t len );
extern int tcp_open ( struct stream_application *app );
extern struct tcpip_protocol tcp_protocol;