2
0
mirror of https://github.com/xcat2/xNBA.git synced 2025-01-11 10:17:49 +00:00

Make all TCP methods optional; at least FTP data is a read-only

connection and so legitimately ignores acked() and senddata().
This commit is contained in:
Michael Brown 2006-04-30 13:20:40 +00:00
parent aec0e127d2
commit 04b6a1e004
2 changed files with 11 additions and 46 deletions

View File

@ -137,20 +137,20 @@ void uip_tcp_appcall ( void ) {
assert ( conn->tcp_op->newdata != NULL );
assert ( conn->tcp_op->senddata != NULL );
if ( uip_aborted() && op->aborted ) /* optional method */
if ( uip_aborted() && op->aborted )
op->aborted ( conn );
if ( uip_timedout() && op->timedout ) /* optional method */
if ( uip_timedout() && op->timedout )
op->timedout ( conn );
if ( uip_closed() && op->closed ) /* optional method */
if ( uip_closed() && op->closed )
op->closed ( conn );
if ( uip_connected() )
if ( uip_connected() && op->connected )
op->connected ( conn );
if ( uip_acked() )
if ( uip_acked() && op->acked )
op->acked ( conn, uip_conn->len );
if ( uip_newdata() )
if ( uip_newdata() && op->newdata )
op->newdata ( conn, ( void * ) uip_appdata, uip_len );
if ( uip_rexmit() || uip_newdata() || uip_acked() ||
uip_connected() || uip_poll() )
if ( ( uip_rexmit() || uip_newdata() || uip_acked() ||
uip_connected() || uip_poll() ) && op->senddata )
op->senddata ( conn );
}
@ -194,7 +194,7 @@ static void tcp_periodic ( void ) {
* This calls tcp_periodic() at regular intervals.
*/
static void tcp_step ( struct process *process ) {
static long timeout = 0;
static unsigned long timeout = 0;
if ( currticks() > timeout ) {
timeout = currticks() + ( TICKS_PER_SEC / 10 );

View File

@ -58,19 +58,13 @@ static void ftp_closed ( struct tcp_connection *conn ) {
ftp_complete ( ftp, 1 );
}
static void ftp_connected ( struct tcp_connection *conn ) {
struct ftp_request *ftp = tcp_to_ftp ( conn );
/* Nothing to do */
}
static void ftp_acked ( struct tcp_connection *conn, size_t len ) {
struct ftp_request *ftp = tcp_to_ftp ( conn );
ftp->already_sent += len;
}
static int ftp_open_passive ( struct ftp_request *ftp ) {
int ftp_open_passive ( struct ftp_request *ftp ) {
char *ptr = ftp->passive_text;
uint8_t *byte = ( uint8_t * ) ( &ftp->tcp_data.sin );
int i;
@ -90,7 +84,7 @@ static int ftp_open_passive ( struct ftp_request *ftp ) {
return 0;
}
static void ftp_reply ( struct ftp_request *ftp ) {
void ftp_reply ( struct ftp_request *ftp ) {
char status_major = ftp->status_text[0];
int success;
@ -190,7 +184,6 @@ static struct tcp_operations ftp_tcp_operations = {
.aborted = ftp_aborted,
.timedout = ftp_timedout,
.closed = ftp_closed,
.connected = ftp_connected,
.acked = ftp_acked,
.newdata = ftp_newdata,
.senddata = ftp_senddata,
@ -208,24 +201,6 @@ static void ftp_data_timedout ( struct tcp_connection *conn ) {
ftp_complete ( ftp, -ETIMEDOUT );
}
static void ftp_data_closed ( struct tcp_connection *conn ) {
struct ftp_request *ftp = tcp_to_ftp_data ( conn );
/* Nothing to do */
}
static void ftp_data_connected ( struct tcp_connection *conn ) {
struct ftp_request *ftp = tcp_to_ftp_data ( conn );
/* Nothing to do */
}
static void ftp_data_acked ( struct tcp_connection *conn, size_t len ) {
struct ftp_request *ftp = tcp_to_ftp_data ( conn );
/* Nothing to do */
}
static void ftp_data_newdata ( struct tcp_connection *conn,
void *data, size_t len ) {
struct ftp_request *ftp = tcp_to_ftp_data ( conn );
@ -233,20 +208,10 @@ static void ftp_data_newdata ( struct tcp_connection *conn,
ftp->callback ( data, len );
}
static void ftp_data_senddata ( struct tcp_connection *conn ) {
struct ftp_request *ftp = tcp_to_ftp_data ( conn );
/* Nothing to do */
}
static struct tcp_operations ftp_data_tcp_operations = {
.aborted = ftp_data_aborted,
.timedout = ftp_data_timedout,
.closed = ftp_data_closed,
.connected = ftp_data_connected,
.acked = ftp_data_acked,
.newdata = ftp_data_newdata,
.senddata = ftp_data_senddata,
};
/**