From 6d32f0e6e2179afa4e78ab94d3fbfb691a6f99de Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 31 Jan 2007 02:09:13 +0000 Subject: Changed to use the generic stream API. --- src/include/gpxe/ftp.h | 10 ++--- src/include/gpxe/http.h | 6 +-- src/include/gpxe/iscsi.h | 8 ++-- src/include/gpxe/stream.h | 7 +++- src/include/gpxe/tcp.h | 101 +--------------------------------------------- 5 files changed, 19 insertions(+), 113 deletions(-) (limited to 'src/include') diff --git a/src/include/gpxe/ftp.h b/src/include/gpxe/ftp.h index 64e8d4e4f..41eca8ca4 100644 --- a/src/include/gpxe/ftp.h +++ b/src/include/gpxe/ftp.h @@ -9,7 +9,7 @@ #include #include -#include +#include 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, diff --git a/src/include/gpxe/http.h b/src/include/gpxe/http.h index 3cfc888a4..911a74851 100644 --- a/src/include/gpxe/http.h +++ b/src/include/gpxe/http.h @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include @@ -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 */ diff --git a/src/include/gpxe/iscsi.h b/src/include/gpxe/iscsi.h index 745606496..62b789c24 100644 --- a/src/include/gpxe/iscsi.h +++ b/src/include/gpxe/iscsi.h @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include @@ -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 diff --git a/src/include/gpxe/stream.h b/src/include/gpxe/stream.h index 8d1c5f5de..545bfae79 100644 --- a/src/include/gpxe/stream.h +++ b/src/include/gpxe/stream.h @@ -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 */ diff --git a/src/include/gpxe/tcp.h b/src/include/gpxe/tcp.h index f618ae32e..576898e86 100644 --- a/src/include/gpxe/tcp.h +++ b/src/include/gpxe/tcp.h @@ -11,6 +11,7 @@ #include "latch.h" #include +#include /** * 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; -- cgit v1.2.3-55-g7522