[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [obfsproxy/master] Use generic SOCKS_* definitions, instead of using the SOCKS5_* ones as generic.
commit 641f44e875b350686e7647c9e6ca77514b75a542
Author: George Kadianakis <desnacked@xxxxxxxxx>
Date: Tue May 24 04:02:14 2011 +0200
Use generic SOCKS_* definitions, instead of using the SOCKS5_* ones as generic.
---
src/network.c | 4 ++--
src/socks.c | 5 +++--
src/socks.h | 8 +++++---
src/test/unittest_socks.c | 10 +++++-----
4 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/src/network.c b/src/network.c
index 258d382..7b017b5 100644
--- a/src/network.c
+++ b/src/network.c
@@ -358,7 +358,7 @@ output_event_cb(struct bufferevent *bev, short what, void *arg)
bufferevent_enable(conn->input, EV_WRITE);
bufferevent_disable(conn->input, EV_READ);
socks_send_reply(conn->socks_state, bufferevent_get_output(conn->input),
- SOCKS5_REP_FAIL);
+ SOCKS_FAILED);
bufferevent_setcb(conn->input, NULL,
close_conn_on_flush, output_event_cb, conn);
return;
@@ -400,7 +400,7 @@ output_event_cb(struct bufferevent *bev, short what, void *arg)
socks_state_set_address(conn->socks_state, sa);
}
socks_send_reply(conn->socks_state, bufferevent_get_output(conn->input),
- SOCKS5_REP_SUCCESS);
+ SOCKS_SUCCESS);
/* we sent a socks reply. We can finally move over to being a regular
input bufferevent. */
socks_state_free(conn->socks_state);
diff --git a/src/socks.c b/src/socks.c
index 6144e26..5d73965 100644
--- a/src/socks.c
+++ b/src/socks.c
@@ -192,7 +192,8 @@ socks5_send_reply(struct evbuffer *reply_dest, socks_state_t *state,
/* We either failed or succeded.
Either way, we should send something back to the client */
p[0] = SOCKS5_VERSION; /* Version field */
- p[1] = (unsigned char) status; /* Reply field */
+ /* Reply field */
+ p[1] = (status == SOCKS_SUCCESS) ? SOCKS5_SUCCESS : SOCKS5_FAILED;
p[2] = 0; /* Reserved */
if (state->parsereq.af == AF_UNSPEC) {
addrlen = 1;
@@ -376,7 +377,7 @@ socks4_send_reply(struct evbuffer *dest, socks_state_t *state, int status)
/* Nul byte */
msg[0] = 0;
/* convert to socks4 status */
- msg[1] = (status == SOCKS5_REP_SUCCESS) ? SOCKS4_SUCCESS : SOCKS4_FAILED;
+ msg[1] = (status == SOCKS_SUCCESS) ? SOCKS4_SUCCESS : SOCKS4_FAILED;
memcpy(msg+2, &portnum, 2);
/* ASN: What should we do here in the case of an FQDN request? */
memcpy(msg+4, &in.s_addr, 4);
diff --git a/src/socks.h b/src/socks.h
index 37c94cc..589cd9c 100644
--- a/src/socks.h
+++ b/src/socks.h
@@ -29,9 +29,11 @@ int socks_state_get_address(const socks_state_t *state,
int socks_state_set_address(socks_state_t *state, const struct sockaddr *sa);
int socks_send_reply(socks_state_t *state, struct evbuffer *dest, int status);
-#define SOCKS5_REP_SUCCESS 0x0
-/* XXX there are more response codes than this! */
-#define SOCKS5_REP_FAIL 0x01
+#define SOCKS_SUCCESS 0x0
+#define SOCKS_FAILED 0x01
+
+#define SOCKS5_SUCCESS 0x0
+#define SOCKS5_FAILED 0x01
#ifdef SOCKS_PRIVATE
diff --git a/src/test/unittest_socks.c b/src/test/unittest_socks.c
index cc68528..8f06d51 100644
--- a/src/test/unittest_socks.c
+++ b/src/test/unittest_socks.c
@@ -301,7 +301,7 @@ test_socks_socks5_request_reply(void *data)
We ask the server to send us a reply on an IPv4 request with
succesful status. */
tt_int_op(1, ==, socks5_send_reply(reply_dest,
- state, SOCKS5_REP_SUCCESS));
+ state, SOCKS_SUCCESS));
uchar rep1[255];
evbuffer_remove(reply_dest,rep1,255); /* yes, this is dirty */
@@ -323,7 +323,7 @@ test_socks_socks5_request_reply(void *data)
strcpy(state->parsereq.addr, "d:1:5:e:a:5:e:0");
tt_int_op(1, ==, socks5_send_reply(reply_dest,
- state, SOCKS5_REP_SUCCESS));
+ state, SOCKS_SUCCESS));
uchar rep2[255];
evbuffer_remove(reply_dest,rep2,255);
@@ -348,7 +348,7 @@ test_socks_socks5_request_reply(void *data)
strcpy(state->parsereq.addr, fqdn);
tt_int_op(1, ==, socks5_send_reply(reply_dest,
- state, SOCKS5_REP_FAIL));
+ state, SOCKS_FAILED));
uchar rep3[255];
evbuffer_remove(reply_dest,rep3,255);
@@ -534,7 +534,7 @@ test_socks_socks4_request_reply(void *data)
We ask the server to send us a reply on an IPv4 request with
succesful status. */
tt_int_op(1, ==, socks4_send_reply(reply_dest,
- state, SOCKS5_REP_SUCCESS));
+ state, SOCKS_SUCCESS));
uchar rep1[255];
evbuffer_remove(reply_dest,rep1,255); /* yes, this is dirty */
@@ -558,7 +558,7 @@ test_socks_socks4_request_reply(void *data)
strcpy(state->parsereq.addr, fqdn);
tt_int_op(1, ==, socks4_send_reply(reply_dest,
- state, SOCKS5_REP_FAIL));
+ state, SOCKS_FAILED));
uchar rep2[255];
evbuffer_remove(reply_dest,rep2,255);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits