commit e7f71a5aa2084c9678c2cbfd83486491e16ca85c Author: Zack Weinberg zackw@panix.com Date: Tue Feb 28 09:50:36 2012 -0800
Remove wrapper functions for steg-to-conn hint methods.
Also removes the distinction between cease_transmission() and close_after_transmit(), which turned out to be unnecessary. --- src/connections.cc | 26 -------------------------- src/connections.h | 33 ++++++--------------------------- src/protocol.h | 3 --- src/protocol/chop.cc | 7 ------- src/steg/embed.cc | 16 ++++++++-------- src/steg/http.cc | 6 +++--- src/steg/jsSteg.cc | 5 ++--- src/steg/nosteg_rr.cc | 10 +++------- src/steg/pdfSteg.cc | 4 ++-- src/steg/swfSteg.cc | 6 ++---- 10 files changed, 26 insertions(+), 90 deletions(-)
diff --git a/src/connections.cc b/src/connections.cc index f116231..39191b2 100644 --- a/src/connections.cc +++ b/src/connections.cc @@ -146,32 +146,6 @@ conn_send_eof(conn_t *dest) } /* otherwise, it's already been done */ }
-/* Protocol methods of connections. */ - -void -conn_expect_close(conn_t *conn) -{ - conn->expect_close(); -} - -void -conn_cease_transmission(conn_t *conn) -{ - conn->cease_transmission(); -} - -void -conn_close_after_transmit(conn_t *conn) -{ - conn->close_after_transmit(); -} - -void -conn_transmit_soon(conn_t *conn, unsigned long timeout) -{ - conn->transmit_soon(timeout); -} - /* Circuits. */
/* The flush timer is used to ensure forward progress for protocols diff --git a/src/connections.h b/src/connections.h index 2b6388b..9b51ce5 100644 --- a/src/connections.h +++ b/src/connections.h @@ -60,8 +60,9 @@ struct conn_t { depending on the protocol. */ virtual int recv_eof() = 0;
- /* The next four methods are for the use of steganography modules. - If you don't use steganography modules, you can use protocol.h's + /* The next several conn_t methods are used by steganography modules + to provide hints about appropriate higher-level behavior. + If your protocol doesn't use steganography modules, use protocol.h's PROTO_STEG_STUBS to define stubs that crash if called. */
/** It is an error if any further data is received from the remote @@ -72,10 +73,6 @@ struct conn_t { on this connection. However, the peer may still send data back. */ virtual void cease_transmission() = 0;
- /** After all pending data is transmitted, close this connection. - (This is stronger than cease_transmission - no reply is expected.) */ - virtual void close_after_transmit() = 0; - /** If TIMEOUT milliseconds elapse without anything having been transmitted on this connection, you need to make up some data and send it. */ @@ -84,9 +81,9 @@ struct conn_t {
/** When all currently-open connections and circuits are closed, stop the main event loop and exit the program. If 'barbaric' is true, - forcibly close them all now, then stop the event loop. It - is a bug to call any function that creates connections or circuits - after conn_start_shutdown has been called. */ + forcibly close them all now, then stop the event loop. + It is a bug to call any function that creates connections or + circuits after conn_start_shutdown has been called. */ void conn_start_shutdown(int barbaric);
/** Create a new inbound connection from a configuration and a @@ -100,24 +97,6 @@ size_t conn_count(void); void conn_send_eof(conn_t *conn); void conn_do_flush(conn_t *conn);
-/* The next several conn_t methods are used by steganography modules to - provide hints about appropriate higher-level behavior. */ - -/** The peer is expected to close CONN without any further - transmissions. */ -void conn_expect_close(conn_t *conn); - -/** Do not transmit any more data on this connection after the outbound - queue has drained. However, the peer may still send data back. */ -void conn_cease_transmission(conn_t *conn); - -/** Close CONN after all pending data is transmitted. */ -void conn_close_after_transmit(conn_t *conn); - -/** We must transmit something on this connection within TIMEOUT - milliseconds. */ -void conn_transmit_soon(conn_t *conn, unsigned long timeout); - /** This struct holds all the state for an "upstream" connection to the higher-level client or server that we are proxying traffic for. It diff --git a/src/protocol.h b/src/protocol.h index a0aca6a..4f0d6cd 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -123,7 +123,6 @@ extern const proto_module *const supported_protos[]; virtual int recv_eof(); \ virtual void expect_close(); \ virtual void cease_transmission(); \ - virtual void close_after_transmit(); \ virtual void transmit_soon(unsigned long timeout) \ /* deliberate absence of semicolon */
@@ -132,8 +131,6 @@ extern const proto_module *const supported_protos[]; { log_abort(this, "steg stub called"); } \ void mod##_conn_t::cease_transmission() \ { log_abort(this, "steg stub called"); } \ - void mod##_conn_t::close_after_transmit() \ - { log_abort(this, "steg stub called"); } \ void mod##_conn_t::transmit_soon(unsigned long) \ { log_abort(this, "steg stub called"); }
diff --git a/src/protocol/chop.cc b/src/protocol/chop.cc index d7607c4..82badde 100644 --- a/src/protocol/chop.cc +++ b/src/protocol/chop.cc @@ -1366,13 +1366,6 @@ chop_conn_t::cease_transmission() }
void -chop_conn_t::close_after_transmit() -{ - this->no_more_transmissions = true; - conn_do_flush(this); -} - -void chop_conn_t::transmit_soon(unsigned long milliseconds) { struct timeval tv; diff --git a/src/steg/embed.cc b/src/steg/embed.cc index 1f14716..e2f12a0 100644 --- a/src/steg/embed.cc +++ b/src/steg/embed.cc @@ -166,10 +166,10 @@ int embed::transmit(struct evbuffer *source, conn_t *conn) { // check if this trace is finished and whether we need to send again if (advance_packet()) { log_debug("send finished trace"); - conn_close_after_transmit(conn); + conn->cease_transmission(); } else if (is_outgoing()) { log_debug("sending again in %d ms", get_pkt_time()); - conn_transmit_soon(conn, get_pkt_time()); + conn->transmit_soon(get_pkt_time()); }
// update last time @@ -210,23 +210,23 @@ int embed::receive(conn_t *conn, struct evbuffer *dest) { } } pkt_size += data_len + 2; - + // read padding if (exp_pkt_size > pkt_size) { size_t padding = exp_pkt_size - pkt_size; if (evbuffer_drain(source, padding) == -1) return -1; } - + src_len -= exp_pkt_size; pkt_size = 0;
log_debug("received packet %d of trace %d", cur_pkt, cur_idx); - + // advance packet; if done with trace, sender should close connection if (advance_packet()) { - conn_cease_transmission(conn); - conn_expect_close(conn); + conn->cease_transmission(); + conn->expect_close(); log_debug("received last packet in trace"); return 0; } @@ -234,7 +234,7 @@ int embed::receive(conn_t *conn, struct evbuffer *dest) {
if (is_outgoing()) { log_debug("preparing to send in %d ms", get_pkt_time()); - conn_transmit_soon(conn, get_pkt_time()); + conn->transmit_soon(get_pkt_time()); }
log_debug("remaining source length: %d", src_len); diff --git a/src/steg/http.cc b/src/steg/http.cc index aa57b63..302571d 100644 --- a/src/steg/http.cc +++ b/src/steg/http.cc @@ -369,7 +369,7 @@ http_client_cookie_transmit (http *s, struct evbuffer *source, conn_t *conn) {
evbuffer_drain(source, sbuflen); log_debug("CLIENT TRANSMITTED payload %d\n", (int) sbuflen); - conn_cease_transmission(conn); + conn->cease_transmission();
s->type = find_uri_type(buf, bufsize); s->have_transmitted = true; @@ -530,7 +530,7 @@ http_client_uri_transmit (http *s, struct evbuffer *source, conn_t *conn) {
evbuffer_drain(source, slen); - conn_cease_transmission(conn); + conn->cease_transmission(); s->type = find_uri_type(outbuf, sizeof(outbuf)); s->have_transmitted = 1; return 0; @@ -694,7 +694,7 @@ http_server_receive(http *s, conn_t *conn, struct evbuffer *dest, struct evbuffe s->have_received = 1; s->type = type;
- conn_transmit_soon(conn, 100); + conn->transmit_soon(100); return RECV_GOOD; }
diff --git a/src/steg/jsSteg.cc b/src/steg/jsSteg.cc index 8bc56de..335b78e 100644 --- a/src/steg/jsSteg.cc +++ b/src/steg/jsSteg.cc @@ -874,7 +874,7 @@ http_server_JS_transmit (steg_t*, struct evbuffer *source, conn_t *conn, unsigne evbuffer_drain(source, sbuflen);
free(outbuf2); - conn_close_after_transmit(conn); + conn->cease_transmission(); // downcast_steg(s)->have_transmitted = 1; return 0; } @@ -1075,8 +1075,7 @@ http_handle_client_JS_receive(steg_t *, conn_t *conn, struct evbuffer *dest, str log_debug("Drained source for %d char\n", response_len);
// downcast_steg(s)->have_received = 1; - conn_expect_close(conn); - + conn->expect_close(); return RECV_GOOD; }
diff --git a/src/steg/nosteg_rr.cc b/src/steg/nosteg_rr.cc index 3aa543d..a586d0a 100644 --- a/src/steg/nosteg_rr.cc +++ b/src/steg/nosteg_rr.cc @@ -80,11 +80,7 @@ nosteg_rr::transmit(struct evbuffer *source, conn_t *conn) }
can_transmit = false; - if (is_clientside) { - conn_cease_transmission(conn); - } else { - conn_close_after_transmit(conn); - } + conn->cease_transmission();
return 0; } @@ -104,10 +100,10 @@ nosteg_rr::receive(conn_t *conn, struct evbuffer *dest) }
if (is_clientside) { - conn_expect_close(conn); + conn->expect_close(); } else { can_transmit = true; - conn_transmit_soon(conn, 100); + conn->transmit_soon(100); }
return 0; diff --git a/src/steg/pdfSteg.cc b/src/steg/pdfSteg.cc index 525e494..504c3d4 100644 --- a/src/steg/pdfSteg.cc +++ b/src/steg/pdfSteg.cc @@ -422,7 +422,7 @@ int http_server_PDF_transmit (steg_t*, struct evbuffer *source, conn_t *conn) {
evbuffer_drain(source, sbuflen);
- conn_close_after_transmit(conn); + conn->cease_transmission(); // downcast_steg(s)->have_transmitted = 1; return 0; } @@ -502,7 +502,7 @@ http_handle_client_PDF_receive(steg_t *, conn_t *conn, struct evbuffer *dest, st }
// downcast_steg(s)->have_received = 1; - conn_expect_close(conn); + conn->expect_close(); return RECV_GOOD; }
diff --git a/src/steg/swfSteg.cc b/src/steg/swfSteg.cc index 2e118a4..d7c35ec 100644 --- a/src/steg/swfSteg.cc +++ b/src/steg/swfSteg.cc @@ -160,9 +160,7 @@ http_server_SWF_transmit (steg_t*, struct evbuffer *source, conn_t *conn) { }
- // conn_cease_transmission(conn); - conn_close_after_transmit(conn); - + conn->cease_transmission();
free(inbuf); free(outbuf); @@ -249,6 +247,6 @@ http_handle_client_SWF_receive(steg_t *, conn_t *conn, struct evbuffer *dest, st }
// downcast_steg(s)->have_received = 1; - conn_expect_close(conn); + conn->expect_close(); return RECV_GOOD; }
tor-commits@lists.torproject.org