[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stegotorus/master] Remove many trivial wrapper functions around conn_t/circuit_t methods.



commit d62e145dab0dd07a302daca5087eb0e44fa50591
Author: Zack Weinberg <zackw@xxxxxxxxx>
Date:   Tue Feb 28 08:36:42 2012 -0800

    Remove many trivial wrapper functions around conn_t/circuit_t methods.
---
 src/connections.cc            |   78 +++++------------------------------------
 src/connections.h             |   43 ++++++----------------
 src/network.cc                |   50 +++++++++++++-------------
 src/protocol/chop.cc          |   18 +++++-----
 src/protocol/null.cc          |   12 +++---
 src/steg/embed.cc             |    4 +-
 src/steg/http.cc              |    6 ++--
 src/steg/jsSteg.cc            |    2 +-
 src/steg/nosteg.cc            |    4 +-
 src/steg/nosteg_rr.cc         |    4 +-
 src/steg/pdfSteg.cc           |    2 +-
 src/steg/swfSteg.cc           |    2 +-
 src/test/unittest.cc          |   12 +++---
 src/test/unittest_transfer.cc |   24 ++++++------
 14 files changed, 91 insertions(+), 170 deletions(-)

diff --git a/src/connections.cc b/src/connections.cc
index f16d71e..f116231 100644
--- a/src/connections.cc
+++ b/src/connections.cc
@@ -59,14 +59,14 @@ conn_start_shutdown(int barbaric)
       v.swap(circuits);
       for (unordered_set<circuit_t *>::iterator i = v.begin();
            i != v.end(); i++)
-        circuit_close(*i);
+        delete *i;
     }
     if (!connections.empty()) {
       unordered_set<conn_t *> v;
       v.swap(connections);
       for (unordered_set<conn_t *>::iterator i = v.begin();
            i != v.end(); i++)
-        conn_close(*i);
+        delete *i;
     }
     closing_all_connections = false;
   }
@@ -130,17 +130,11 @@ conn_t::circuit() const
   return 0;
 }
 
-void
-conn_close(conn_t *conn)
-{
-  delete conn;
-}
-
 /* Drain the transmit queue and send a TCP-level EOF indication to DEST. */
 void
 conn_send_eof(conn_t *dest)
 {
-  struct evbuffer *outbuf = conn_get_outbound(dest);
+  struct evbuffer *outbuf = dest->outbound();
   if (evbuffer_get_length(outbuf)) {
     log_debug(dest, "flushing out %lu bytes",
               (unsigned long) evbuffer_get_length(outbuf));
@@ -154,30 +148,6 @@ conn_send_eof(conn_t *dest)
 
 /* Protocol methods of connections. */
 
-int
-conn_maybe_open_upstream(conn_t *conn)
-{
-  return conn->maybe_open_upstream();
-}
-
-int
-conn_handshake(conn_t *conn)
-{
-  return conn->handshake();
-}
-
-int
-conn_recv(conn_t *source)
-{
-  return source->recv();
-}
-
-int
-conn_recv_eof(conn_t *source)
-{
-  return source->recv_eof();
-}
-
 void
 conn_expect_close(conn_t *conn)
 {
@@ -231,7 +201,7 @@ axe_timer_cb(evutil_socket_t, short, void *arg)
       evbuffer_get_length(bufferevent_get_output(ckt->up_buffer)) > 0)
     circuit_do_flush(ckt);
   else
-    circuit_close(ckt);
+    delete ckt;
 }
 
 circuit_t *
@@ -279,12 +249,6 @@ circuit_t::cfg() const
 }
 
 void
-circuit_close(circuit_t *ckt)
-{
-  delete ckt;
-}
-
-void
 circuit_add_upstream(circuit_t *ckt, struct bufferevent *buf, const char *peer)
 {
   log_assert(!ckt->up_buffer);
@@ -297,47 +261,23 @@ circuit_add_upstream(circuit_t *ckt, struct bufferevent *buf, const char *peer)
 /* circuit_open_upstream is in network.c */
 
 void
-circuit_add_downstream(circuit_t *ckt, conn_t *down)
-{
-  ckt->add_downstream(down);
-}
-
-void
-circuit_drop_downstream(circuit_t *ckt, conn_t *down)
-{
-  ckt->drop_downstream(down);
-}
-
-static int
-circuit_send_raw(circuit_t *ckt)
-{
-  return ckt->send();
-}
-
-void
 circuit_send(circuit_t *ckt)
 {
-  if (circuit_send_raw(ckt)) {
+  if (ckt->send()) {
     log_info(ckt, "error during transmit");
-    circuit_close(ckt);
+    delete ckt;
   }
 }
 
-static int
-circuit_send_eof_raw(circuit_t *ckt)
-{
-  return ckt->send_eof();
-}
-
 void
 circuit_send_eof(circuit_t *ckt)
 {
   if (ckt->socks_state) {
     log_debug(ckt, "EOF during SOCKS phase");
-    circuit_close(ckt);
-  } else if (circuit_send_eof_raw(ckt)) {
+    delete ckt;
+  } else if (ckt->send_eof()) {
     log_info(ckt, "error during transmit");
-    circuit_close(ckt);
+    delete ckt;
   }
 }
 
diff --git a/src/connections.h b/src/connections.h
index 099a8a6..2b6388b 100644
--- a/src/connections.h
+++ b/src/connections.h
@@ -21,6 +21,10 @@ struct conn_t {
   bool                flushing : 1;
 
   conn_t() : connected(false), flushing(false) {}
+
+  /** Close and deallocate a connection.  If the connection is part of a
+      circuit, disconnect it from the circuit; this may cause the circuit
+      to close as well. */
   virtual ~conn_t();
 
   /** Return the upstream circuit for this connection, if there is one.
@@ -28,6 +32,14 @@ struct conn_t {
       legitimately after the subclass destructor has run. */
   virtual circuit_t *circuit() const;
 
+  /** Retrieve the inbound evbuffer for this connection. */
+  struct evbuffer *inbound() const
+  { return this->buffer ? bufferevent_get_input(this->buffer) : 0; }
+
+  /** Retrieve the outbound evbuffer for this connection. */
+  struct evbuffer *outbound()
+  { return this->buffer ? bufferevent_get_output(this->buffer) : 0; }
+
   /** Create an upstream circuit for this connection, if it is
       possible to do so without receiving data from the downstream
       peer.  If data must be received first, this method should do
@@ -82,36 +94,9 @@ void conn_start_shutdown(int barbaric);
 conn_t *conn_create(config_t *cfg, size_t index, struct bufferevent *buf,
                     const char *peername);
 
-/** Close and deallocate a connection.  If the connection is part of a
-    circuit, close the other side of that circuit as well. */
-void conn_close(conn_t *conn);
-
 /** Report the number of currently-open connections. */
 size_t conn_count(void);
 
-/** Retrieve the inbound evbuffer for a connection. */
-static inline struct evbuffer *conn_get_inbound(conn_t *conn)
-{ return conn->buffer ? bufferevent_get_input(conn->buffer) : NULL; }
-
-/** Retrieve the outbound evbuffer for a connection. */
-static inline struct evbuffer *conn_get_outbound(conn_t *conn)
-{ return conn->buffer ? bufferevent_get_output(conn->buffer) : NULL; }
-
-/** Connect to upstream, if it is possible to do so without receiving
-    data from the downstream peer first. */
-int conn_maybe_open_upstream(conn_t *conn);
-
-/** Transmit the protocol-specific handshake message (if any) for a
-    connection. */
-int conn_handshake(conn_t *conn);
-
-/** Receive data from SOURCE, decode it, and write it to upstream. */
-int conn_recv(conn_t *source);
-
-/** No more data will be received from the peer; flush any internally
-    buffered data to your upstream. */
-int conn_recv_eof(conn_t *source);
-
 void conn_send_eof(conn_t *conn);
 void conn_do_flush(conn_t *conn);
 
@@ -187,12 +172,8 @@ void circuit_add_upstream(circuit_t *ckt,
                           struct bufferevent *buf, const char *peer);
 int circuit_open_upstream(circuit_t *ckt);
 
-void circuit_add_downstream(circuit_t *ckt, conn_t *down);
-void circuit_drop_downstream(circuit_t *ckt, conn_t *down);
-
 void circuit_reopen_downstreams(circuit_t *ckt);
 
-void circuit_close(circuit_t *ckt);
 void circuit_recv_eof(circuit_t *ckt);
 
 void circuit_send(circuit_t *ckt);
diff --git a/src/network.cc b/src/network.cc
index 3cbc1e7..794e4e2 100644
--- a/src/network.cc
+++ b/src/network.cc
@@ -223,16 +223,16 @@ server_listener_cb(struct evconnlistener *, evutil_socket_t fd,
   }
 
   /* If appropriate at this point, connect to upstream. */
-  if (conn_maybe_open_upstream(conn) < 0) {
+  if (conn->maybe_open_upstream() < 0) {
     log_debug(conn, "error opening upstream circuit");
-    conn_close(conn);
+    delete conn;
     return;
   }
 
   /* Queue handshake, if any. */
-  if (conn_handshake(conn) < 0) {
+  if (conn->handshake() < 0) {
     log_debug(conn, "error during handshake");
-    conn_close(conn);
+    delete conn;
     return;
   }
 
@@ -275,7 +275,7 @@ socks_read_cb(struct bufferevent *bev, void *arg)
   if (socks_ret == SOCKS_INCOMPLETE)
     return; /* need to read more data. */
   else if (socks_ret == SOCKS_BROKEN)
-    circuit_close(ckt); /* XXXX send socks reply */
+    delete ckt; /* XXXX send socks reply */
   else if (socks_ret == SOCKS_CMD_NOT_CONNECT) {
     bufferevent_enable(bev, EV_WRITE);
     bufferevent_disable(bev, EV_READ);
@@ -315,9 +315,9 @@ downstream_read_cb(struct bufferevent *bev, void *arg)
   log_debug(down, "%lu bytes available",
             (unsigned long)evbuffer_get_length(bufferevent_get_input(bev)));
 
-  if (conn_recv(down)) {
+  if (down->recv()) {
     log_debug(down, "error during receive");
-    conn_close(down);
+    delete down;
   }
 }
 
@@ -353,10 +353,10 @@ upstream_event_cb(struct bufferevent *bev, short what, void *arg)
         log_debug(ckt, "acknowledging EOF upstream");
         shutdown(bufferevent_getfd(bev), SHUT_RD);
       } else {
-        circuit_close(ckt);
+        delete ckt;
       }
     } else {
-      circuit_close(ckt);
+      delete ckt;
     }
   } else {
     /* We should never get BEV_EVENT_CONNECTED here.
@@ -391,16 +391,16 @@ downstream_event_cb(struct bufferevent *bev, short what, void *arg)
 
     if (what == (BEV_EVENT_EOF|BEV_EVENT_READING)) {
       /* Peer is done sending us data. */
-      conn_recv_eof(conn);
+      conn->recv_eof();
       if (bufferevent_get_enabled(bev) ||
           evbuffer_get_length(bufferevent_get_input(bev)) > 0) {
         log_debug(conn, "acknowledging EOF downstream");
         shutdown(bufferevent_getfd(bev), SHUT_RD);
       } else {
-        conn_close(conn);
+        delete conn;
       }
     } else {
-      conn_close(conn);
+      delete conn;
     }
   } else {
     /* We should never get BEV_EVENT_CONNECTED here.
@@ -431,7 +431,7 @@ upstream_flush_cb(struct bufferevent *bev, void *arg)
       log_debug(ckt, "sending EOF upstream");
       shutdown(bufferevent_getfd(bev), SHUT_WR);
     } else {
-      circuit_close(ckt);
+      delete ckt;
     }
   }
 }
@@ -455,7 +455,7 @@ downstream_flush_cb(struct bufferevent *bev, void *arg)
       log_debug(conn, "sending EOF downstream");
       shutdown(bufferevent_getfd(bev), SHUT_WR);
     } else {
-      conn_close(conn);
+      delete conn;
     }
   }
 }
@@ -518,9 +518,9 @@ downstream_connect_cb(struct bufferevent *bev, short what, void *arg)
     conn->connected = 1;
 
     /* Queue handshake, if any. */
-    if (conn_handshake(conn) < 0) {
+    if (conn->handshake() < 0) {
       log_debug(conn, "error during handshake");
-      conn_close(conn);
+      delete conn;
       return;
     }
 
@@ -572,7 +572,7 @@ downstream_socks_connect_cb(struct bufferevent *bev, short what, void *arg)
       socks_send_reply(socks, bufferevent_get_output(ckt->up_buffer), err);
       circuit_do_flush(ckt);
     } else {
-      circuit_close(ckt);
+      delete ckt;
     }
     return;
   }
@@ -607,9 +607,9 @@ downstream_socks_connect_cb(struct bufferevent *bev, short what, void *arg)
     conn->connected = 1;
 
     /* Queue handshake, if any. */
-    if (conn_handshake(conn)) {
+    if (conn->handshake()) {
       log_debug(conn, "error during handshake");
-      conn_close(conn);
+      delete conn;
       return;
     }
 
@@ -711,7 +711,7 @@ create_one_outbound_connection(circuit_t *ckt, struct evutil_addrinfo *addr,
 
  success:
   conn = conn_create(cfg, index, buf, peername);
-  circuit_add_downstream(ckt, conn);
+  ckt->add_downstream(conn);
   bufferevent_setcb(buf, downstream_read_cb, downstream_flush_cb,
                     is_socks ? downstream_socks_connect_cb
                     : downstream_connect_cb, conn);
@@ -733,11 +733,11 @@ create_outbound_connections(circuit_t *ckt, bool is_socks)
 
   if (n == 0) {
     log_warn(ckt, "no target addresses available");
-    circuit_close(ckt);
+    delete ckt;
   }
   if (any_successes == 0) {
     log_warn(ckt, "no outbound connections were successful");
-    circuit_close(ckt);
+    delete ckt;
   }
 }
 
@@ -785,7 +785,7 @@ create_outbound_connections_socks(circuit_t *ckt)
 
   /* we don't know the peername yet */
   conn = conn_create(cfg, 0, buf, NULL);
-  circuit_add_downstream(ckt, conn);
+  ckt->add_downstream(conn);
   bufferevent_setcb(buf, downstream_read_cb, downstream_flush_cb,
                     downstream_socks_connect_cb, conn);
   bufferevent_enable(buf, EV_READ|EV_WRITE);
@@ -793,7 +793,7 @@ create_outbound_connections_socks(circuit_t *ckt)
 
  failure:
   /* XXXX send socks reply */
-  circuit_close(ckt);
+  delete ckt;
   if (buf)
     bufferevent_free(buf);
 }
@@ -815,7 +815,7 @@ circuit_do_flush(circuit_t *ckt)
 void
 conn_do_flush(conn_t *conn)
 {
-  size_t remain = evbuffer_get_length(conn_get_outbound(conn));
+  size_t remain = evbuffer_get_length(conn->outbound());
   conn->flushing = 1;
 
   /* If 'remain' is already zero, we have to call the flush callback
diff --git a/src/protocol/chop.cc b/src/protocol/chop.cc
index 832d11b..d7607c4 100644
--- a/src/protocol/chop.cc
+++ b/src/protocol/chop.cc
@@ -806,7 +806,7 @@ chop_find_or_make_circuit(chop_conn_t *conn, uint64_t circuit_id)
     }
     if (circuit_open_upstream(ck)) {
       log_warn(conn, "failed to begin upstream connection");
-      circuit_close(ck);
+      delete ck;
       return -1;
     }
     log_debug(conn, "created new circuit to %s", ck->up_peer);
@@ -814,7 +814,7 @@ chop_find_or_make_circuit(chop_conn_t *conn, uint64_t circuit_id)
     out.first->second = ck;
   }
 
-  circuit_add_downstream(ck, conn);
+  ck->add_downstream(conn);
   return 0;
 }
 
@@ -838,7 +838,7 @@ chop_config_t::~chop_config_t()
   for (chop_circuit_table::iterator i = circuits.begin();
        i != circuits.end(); i++)
     if (i->second)
-      circuit_close(i->second);
+      delete i->second;
 }
 
 bool
@@ -984,10 +984,10 @@ chop_circuit_t::~chop_circuit_t()
        i != this->downstreams.end(); i++) {
     chop_conn_t *conn = *i;
     conn->upstream = NULL;
-    if (evbuffer_get_length(conn_get_outbound(conn)) > 0)
+    if (evbuffer_get_length(conn->outbound()) > 0)
       conn_do_flush(conn);
     else
-      conn_close(conn);
+      delete conn;
   }
 
   delete this->send_crypt;
@@ -1066,7 +1066,7 @@ chop_circuit_t::drop_downstream(conn_t *cn)
            doing it again */
         circuit_do_flush(this);
       else
-        circuit_close(this);
+        delete this;
     } else if (this->config->mode == LSN_SIMPLE_SERVER) {
       circuit_arm_axe_timer(this, this->axe_interval());
     } else {
@@ -1098,7 +1098,7 @@ chop_conn_t::chop_conn_t()
 chop_conn_t::~chop_conn_t()
 {
   if (this->upstream)
-    circuit_drop_downstream(this->upstream, this);
+    this->upstream->drop_downstream(this);
   if (this->steg)
     delete this->steg;
   if (this->must_transmit_timer)
@@ -1340,14 +1340,14 @@ chop_conn_t::recv_eof()
   if (this->upstream) {
     chop_circuit_t *ckt = this->upstream;
 
-    if (evbuffer_get_length(conn_get_inbound(this)) > 0)
+    if (evbuffer_get_length(this->inbound()) > 0)
       if (this->recv())
         return -1;
 
     if ((ckt->sent_fin || this->no_more_transmissions) &&
         (!this->must_transmit_timer ||
          !evtimer_pending(this->must_transmit_timer, NULL)))
-      circuit_drop_downstream(ckt, this);
+      ckt->drop_downstream(this);
   }
   return 0;
 }
diff --git a/src/protocol/null.cc b/src/protocol/null.cc
index 51ea744..989ffd4 100644
--- a/src/protocol/null.cc
+++ b/src/protocol/null.cc
@@ -184,14 +184,14 @@ null_circuit_t::drop_downstream(conn_t *cn)
        doing it again */
     circuit_do_flush(this);
   else
-    circuit_close(this);
+    delete this;
 }
 
 /* Send data from the upstream buffer. */
 int
 null_circuit_t::send()
 {
-  return evbuffer_add_buffer(conn_get_outbound(this->downstream),
+  return evbuffer_add_buffer(this->downstream->outbound(),
                              bufferevent_get_input(this->up_buffer));
 }
 
@@ -225,7 +225,7 @@ null_conn_t::null_conn_t()
 null_conn_t::~null_conn_t()
 {
   if (this->upstream)
-    circuit_drop_downstream(this->upstream, this);
+    this->upstream->drop_downstream(this);
 }
 
 /* Only used by connection callbacks */
@@ -244,7 +244,7 @@ null_conn_t::maybe_open_upstream()
   if (!ckt)
     return -1;
 
-  circuit_add_downstream(ckt, this);
+  ckt->add_downstream(this);
   circuit_open_upstream(ckt);
   return 0;
 }
@@ -262,7 +262,7 @@ null_conn_t::recv()
 {
   log_assert(this->upstream);
   return evbuffer_add_buffer(bufferevent_get_output(this->upstream->up_buffer),
-                             conn_get_inbound(this));
+                             this->inbound());
 }
 
 /** Receive EOF from connection SOURCE */
@@ -270,7 +270,7 @@ int
 null_conn_t::recv_eof()
 {
   if (this->upstream) {
-    if (evbuffer_get_length(conn_get_inbound(this)) > 0)
+    if (evbuffer_get_length(this->inbound()) > 0)
       if (this->recv())
         return -1;
 
diff --git a/src/steg/embed.cc b/src/steg/embed.cc
index 3cac635..1f14716 100644
--- a/src/steg/embed.cc
+++ b/src/steg/embed.cc
@@ -136,7 +136,7 @@ size_t embed::transmit_room(conn_t * /* conn */) {
 }
 
 int embed::transmit(struct evbuffer *source, conn_t *conn) {
-  struct evbuffer *dest = conn_get_outbound(conn);
+  struct evbuffer *dest = conn->outbound();
   short src_len = evbuffer_get_length(source);
   short pkt_size = get_pkt_size();
   short used = src_len + 2;
@@ -178,7 +178,7 @@ int embed::transmit(struct evbuffer *source, conn_t *conn) {
 }
 
 int embed::receive(conn_t *conn, struct evbuffer *dest) {
-  struct evbuffer *source = conn_get_inbound(conn);
+  struct evbuffer *source = conn->inbound();
   short src_len = evbuffer_get_length(source);
   short pkt_size = 0;
 
diff --git a/src/steg/http.cc b/src/steg/http.cc
index 9d296b5..aa57b63 100644
--- a/src/steg/http.cc
+++ b/src/steg/http.cc
@@ -257,7 +257,7 @@ http_client_cookie_transmit (http *s, struct evbuffer *source, conn_t *conn) {
      presently uses the URL. And it can't be binary. */
 
 
-  struct evbuffer *dest = conn_get_outbound(conn);
+  struct evbuffer *dest = conn->outbound();
   size_t sbuflen = evbuffer_get_length(source);
   int bufsize = 10000;
   char* buf = (char*) xmalloc(bufsize);
@@ -457,7 +457,7 @@ int
 http_client_uri_transmit (http *s, struct evbuffer *source, conn_t *conn) {
 
 
-  struct evbuffer *dest = conn_get_outbound(conn);
+  struct evbuffer *dest = conn->outbound();
 
 
   struct evbuffer_iovec *iv;
@@ -711,7 +711,7 @@ http_server_receive(http *s, conn_t *conn, struct evbuffer *dest, struct evbuffe
 int
 http::receive(conn_t *conn, struct evbuffer *dest)
 {
-  struct evbuffer *source = conn_get_inbound(conn);
+  struct evbuffer *source = conn->inbound();
   // unsigned int type;
   int rval = RECV_BAD;
 
diff --git a/src/steg/jsSteg.cc b/src/steg/jsSteg.cc
index 8cbff87..8bc56de 100644
--- a/src/steg/jsSteg.cc
+++ b/src/steg/jsSteg.cc
@@ -711,7 +711,7 @@ http_server_JS_transmit (steg_t*, struct evbuffer *source, conn_t *conn, unsigne
 
   struct evbuffer_iovec *iv;
   int nv;
-  struct evbuffer *dest = conn_get_outbound(conn);
+  struct evbuffer *dest = conn->outbound();
   size_t sbuflen = evbuffer_get_length(source);
   char *hend, *jsTemplate = NULL, *outbuf, *outbuf2;
   char data[(int) sbuflen*2];
diff --git a/src/steg/nosteg.cc b/src/steg/nosteg.cc
index 43971bb..02d2e10 100644
--- a/src/steg/nosteg.cc
+++ b/src/steg/nosteg.cc
@@ -65,7 +65,7 @@ nosteg::transmit_room(conn_t *)
 int
 nosteg::transmit(struct evbuffer *source, conn_t *conn)
 {
-  struct evbuffer *dest = conn_get_outbound(conn);
+  struct evbuffer *dest = conn->outbound();
 
   log_debug(conn, "transmitting %lu bytes",
             (unsigned long)evbuffer_get_length(source));
@@ -81,7 +81,7 @@ nosteg::transmit(struct evbuffer *source, conn_t *conn)
 int
 nosteg::receive(conn_t *conn, struct evbuffer *dest)
 {
-  struct evbuffer *source = conn_get_inbound(conn);
+  struct evbuffer *source = conn->inbound();
 
   log_debug(conn, "receiving %lu bytes",
             (unsigned long)evbuffer_get_length(source));
diff --git a/src/steg/nosteg_rr.cc b/src/steg/nosteg_rr.cc
index 3c8a5a0..3aa543d 100644
--- a/src/steg/nosteg_rr.cc
+++ b/src/steg/nosteg_rr.cc
@@ -69,7 +69,7 @@ nosteg_rr::transmit(struct evbuffer *source, conn_t *conn)
 {
   log_assert(can_transmit);
 
-  struct evbuffer *dest = conn_get_outbound(conn);
+  struct evbuffer *dest = conn->outbound();
 
   log_debug(conn, "transmitting %lu bytes",
             (unsigned long)evbuffer_get_length(source));
@@ -92,7 +92,7 @@ nosteg_rr::transmit(struct evbuffer *source, conn_t *conn)
 int
 nosteg_rr::receive(conn_t *conn, struct evbuffer *dest)
 {
-  struct evbuffer *source = conn_get_inbound(conn);
+  struct evbuffer *source = conn->inbound();
 
   log_debug(conn, "%s-side receiving %lu bytes",
             is_clientside ? "client" : "server",
diff --git a/src/steg/pdfSteg.cc b/src/steg/pdfSteg.cc
index d958b29..525e494 100644
--- a/src/steg/pdfSteg.cc
+++ b/src/steg/pdfSteg.cc
@@ -298,7 +298,7 @@ pdfUnwrap (char *data, unsigned int dlen,
 
 int http_server_PDF_transmit (steg_t*, struct evbuffer *source, conn_t *conn) {
 
-  struct evbuffer *dest = conn_get_outbound(conn);
+  struct evbuffer *dest = conn->outbound();
   size_t sbuflen = evbuffer_get_length(source);
   unsigned int mpdf;
   char *pdfTemplate = NULL, *hend;
diff --git a/src/steg/swfSteg.cc b/src/steg/swfSteg.cc
index 8c3bd2e..2e118a4 100644
--- a/src/steg/swfSteg.cc
+++ b/src/steg/swfSteg.cc
@@ -125,7 +125,7 @@ swf_unwrap(char* inbuf, int in_len, char* outbuf, int out_sz) {
 int 
 http_server_SWF_transmit (steg_t*, struct evbuffer *source, conn_t *conn) {
 
-  struct evbuffer *dest = conn_get_outbound(conn);
+  struct evbuffer *dest = conn->outbound();
   size_t sbuflen = evbuffer_get_length(source);
   char* inbuf;
   char* outbuf;
diff --git a/src/test/unittest.cc b/src/test/unittest.cc
index 37632ac..31d237a 100644
--- a/src/test/unittest.cc
+++ b/src/test/unittest.cc
@@ -55,8 +55,8 @@ setup_proto_test_state(const struct testcase_t *tcase)
   circuit_add_upstream(s->ckt_server, pairs[2][1],
                        xstrdup("to-harness-server"));
 
-  circuit_add_downstream(s->ckt_client, s->conn_client);
-  circuit_add_downstream(s->ckt_server, s->conn_server);
+  s->ckt_client->add_downstream(s->conn_client);
+  s->ckt_server->add_downstream(s->conn_server);
 
   return s;
 }
@@ -68,11 +68,11 @@ cleanup_proto_test_state(const struct testcase_t *, void *state)
 
   /* We don't want to trigger circuit_*_shutdown, so dissociate the circuits
      from their connections and close each separately. */
-  circuit_drop_downstream(s->ckt_client, s->conn_client);
-  circuit_drop_downstream(s->ckt_server, s->conn_server);
+  s->ckt_client->drop_downstream(s->conn_client);
+  s->ckt_server->drop_downstream(s->conn_server);
 
-  conn_close(s->conn_client);
-  conn_close(s->conn_server);
+  delete s->conn_client;
+  delete s->conn_server;
 
   delete s->cfg_client;
   delete s->cfg_server;
diff --git a/src/test/unittest_transfer.cc b/src/test/unittest_transfer.cc
index 520a1e4..d1a7bbf 100644
--- a/src/test/unittest_transfer.cc
+++ b/src/test/unittest_transfer.cc
@@ -22,10 +22,10 @@ test_transfer(void *state)
   const struct proto_test_args *a = s->args;
 
   /* Handshake */
-  tt_int_op(0, ==, conn_handshake(s->conn_client));
-  tt_int_op(0, ==, conn_recv(s->conn_server));
-  tt_int_op(0, ==, conn_handshake(s->conn_server));
-  tt_int_op(0, ==, conn_recv(s->conn_client));
+  tt_int_op(0, ==, s->conn_client->handshake());
+  tt_int_op(0, ==, s->conn_server->recv());
+  tt_int_op(0, ==, s->conn_server->handshake());
+  tt_int_op(0, ==, s->conn_client->recv());
   /* End of Handshake */
 
   /* client -> server */
@@ -33,14 +33,14 @@ test_transfer(void *state)
   circuit_send(s->ckt_client);
   tt_int_op(0, ==, evbuffer_get_length(bufferevent_get_output(s->buf_client)));
   tt_int_op(a->len_c2s_on_wire, ==,
-            evbuffer_get_length(conn_get_inbound(s->conn_server)));
+            evbuffer_get_length(s->conn_server->inbound()));
   tt_mem_op(a->c2s_on_wire, ==,
-            evbuffer_pullup(conn_get_inbound(s->conn_server),
+            evbuffer_pullup(s->conn_server->inbound(),
                             a->len_c2s_on_wire),
             a->len_c2s_on_wire);
 
-  conn_recv(s->conn_server);
-  tt_int_op(0, ==, evbuffer_get_length(conn_get_inbound(s->conn_server)));
+  s->conn_server->recv();
+  tt_int_op(0, ==, evbuffer_get_length(s->conn_server->inbound()));
   tt_int_op(SLEN(msg1), ==,
             evbuffer_get_length(bufferevent_get_input(s->buf_server)));
   tt_mem_op(msg1, ==,
@@ -52,14 +52,14 @@ test_transfer(void *state)
   circuit_send(s->ckt_server);
   tt_int_op(0, ==, evbuffer_get_length(bufferevent_get_output(s->buf_server)));
   tt_int_op(a->len_s2c_on_wire, ==,
-            evbuffer_get_length(conn_get_inbound(s->conn_client)));
+            evbuffer_get_length(s->conn_client->inbound()));
   tt_mem_op(a->s2c_on_wire, ==,
-            evbuffer_pullup(conn_get_inbound(s->conn_client),
+            evbuffer_pullup(s->conn_client->inbound(),
                             a->len_s2c_on_wire),
             a->len_s2c_on_wire);
 
-  conn_recv(s->conn_client);
-  tt_int_op(0, ==, evbuffer_get_length(conn_get_inbound(s->conn_client)));
+  s->conn_client->recv();
+  tt_int_op(0, ==, evbuffer_get_length(s->conn_client->inbound()));
   tt_int_op(SLEN(msg2), ==,
             evbuffer_get_length(bufferevent_get_input(s->buf_client)));
   tt_mem_op(msg2, ==,



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits