[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Handle rendezvous relay cells
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv23523/src/or
Modified Files:
connection_edge.c or.h rendcommon.c rendmid.c rendservice.c
Log Message:
Handle rendezvous relay cells
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -d -r1.133 -r1.134
--- connection_edge.c 3 Apr 2004 03:07:25 -0000 1.133
+++ connection_edge.c 3 Apr 2004 03:37:11 -0000 1.134
@@ -171,7 +171,7 @@
* return -1. Else return 0.
*/
int connection_edge_send_command(connection_t *fromconn, circuit_t *circ,
- int relay_command, void *payload,
+ int relay_command, const char *payload,
int payload_len, crypt_path_t *cpath_layer) {
cell_t cell;
relay_header_t rh;
@@ -433,6 +433,15 @@
connection_start_reading(conn);
connection_edge_package_raw_inbuf(conn); /* handle whatever might still be on the inbuf */
return 0;
+ case RELAY_COMMAND_ESTABLISH_INTRO:
+ case RELAY_COMMAND_ESTABLISH_RENDEZVOUS:
+ case RELAY_COMMAND_INTRODUCE1:
+ case RELAY_COMMAND_INTRODUCE2:
+ case RELAY_COMMAND_RENDEZVOUS1:
+ case RELAY_COMMAND_RENDEZVOUS2:
+ rend_process_relay_cell(circ, rh.command, rh.length,
+ cell->payload+RELAY_HEADER_SIZE);
+ return 0;
}
log_fn(LOG_WARN,"unknown relay command %d.",rh.command);
return -1;
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.291
retrieving revision 1.292
diff -u -d -r1.291 -r1.292
--- or.h 3 Apr 2004 03:06:06 -0000 1.291
+++ or.h 3 Apr 2004 03:37:11 -0000 1.292
@@ -829,7 +829,7 @@
int connection_edge_destroy(uint16_t circ_id, connection_t *conn);
int connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer);
int connection_edge_send_command(connection_t *fromconn, circuit_t *circ,
- int relay_command, void *payload,
+ int relay_command, const char *payload,
int payload_len, crypt_path_t *cpath_layer);
int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
connection_t *conn, int edge_type,
@@ -1044,6 +1044,9 @@
char **intro_points;
} rend_service_descriptor_t;
+void rend_process_relay_cell(circuit_t *circ, int command, int length,
+ const char *payload);
+
void rend_service_descriptor_free(rend_service_descriptor_t *desc);
int rend_encode_service_descriptor(rend_service_descriptor_t *desc,
crypto_pk_env_t *key,
@@ -1058,7 +1061,6 @@
int rend_cache_lookup(char *query, const char **desc, int *desc_len);
int rend_cache_store(char *desc, int desc_len);
-
/********************************* rendservice.c ***************************/
int rend_config_services(or_options_t *options);
@@ -1067,6 +1069,13 @@
void rend_service_intro_is_ready(circuit_t *circuit);
void rend_service_rendezvous_is_ready(circuit_t *circuit);
+int rend_service_introduce(circuit_t *circuit, const char *request, int request_len);
+
+/********************************* rendmid.c *******************************/
+int rend_mid_establish_intro(circuit_t *circ, const char *request, int request_len);
+int rend_mid_introduce(circuit_t *circ, const char *request, int request_len);
+int rend_mid_establish_rendezvous(circuit_t *circ, const char *request, int request_len);
+int rend_mid_rendezvous(circuit_t *circ, const char *request, int request_len);
#endif
Index: rendcommon.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendcommon.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- rendcommon.c 3 Apr 2004 03:33:57 -0000 1.13
+++ rendcommon.c 3 Apr 2004 03:37:11 -0000 1.14
@@ -93,7 +93,11 @@
cp = eos+1;
}
keylen = crypto_pk_keysize(result->pk);
- if (end-cp != keylen) goto truncated;
+ if (end-cp < keylen) goto truncated;
+ if (end-cp > keylen) {
+ log_fn(LOG_WARN, "Signature too long on service descriptor");
+ goto error;
+ }
if (crypto_pk_public_checksig_digest(result->pk,
(char*)str,cp-str, /* data */
(char*)cp,end-cp /* signature*/
@@ -248,6 +252,36 @@
return 0;
}
+/* Dispatch on rendezvous relay command. */
+void rend_process_relay_cell(circuit_t *circ, int command, int length,
+ const char *payload)
+{
+ int r;
+ switch(command) {
+ case RELAY_COMMAND_ESTABLISH_INTRO:
+ r = rend_mid_establish_intro(circ,payload,length);
+ break;
+ case RELAY_COMMAND_ESTABLISH_RENDEZVOUS:
+ r = rend_mid_establish_rendezvous(circ,payload,length);
+ break;
+ case RELAY_COMMAND_INTRODUCE1:
+ r = rend_mid_introduce(circ,payload,length);
+ break;
+ case RELAY_COMMAND_INTRODUCE2:
+ r = rend_service_introduce(circ,payload,length);
+ break;
+ case RELAY_COMMAND_RENDEZVOUS1:
+ r = rend_mid_rendezvous(circ,payload,length);
+ break;
+ case RELAY_COMMAND_RENDEZVOUS2:
+ /* r = rend_client_rendezvous(circ,payload,length); */
+ log_fn(LOG_NOTICE, "Ignoring a rendezvous2 cell");
+ break;
+ default:
+ assert(0);
+ }
+}
+
/*
Local Variables:
mode:c
Index: rendmid.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendmid.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- rendmid.c 3 Apr 2004 02:40:30 -0000 1.6
+++ rendmid.c 3 Apr 2004 03:37:11 -0000 1.7
@@ -8,7 +8,7 @@
* rendevous service.
*/
int
-rend_mid_establish_intro(circuit_t *circ, char *request, int request_len)
+rend_mid_establish_intro(circuit_t *circ, const char *request, int request_len)
{
crypto_pk_env_t *pk = NULL;
char buf[20+9];
@@ -97,7 +97,7 @@
* INTRODUCE2 cell.
*/
int
-rend_mid_introduce(circuit_t *circ, char *request, int request_len)
+rend_mid_introduce(circuit_t *circ, const char *request, int request_len)
{
circuit_t *intro_circ;
char hexid[9];
@@ -149,7 +149,7 @@
* rendezvous cookie.
*/
int
-rend_mid_establish_rendezvous(circuit_t *circ, char *request, int request_len)
+rend_mid_establish_rendezvous(circuit_t *circ, const char *request, int request_len)
{
char hexid[9];
@@ -185,7 +185,7 @@
* relaying the cell's body in a RENDEZVOUS2 cell, and connecting the two circuits.
*/
int
-rend_mid_rendezvous(circuit_t *circ, char *request, int request_len)
+rend_mid_rendezvous(circuit_t *circ, const char *request, int request_len)
{
circuit_t *rend_circ;
char hexid[9];
Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- rendservice.c 3 Apr 2004 03:07:25 -0000 1.18
+++ rendservice.c 3 Apr 2004 03:37:11 -0000 1.19
@@ -302,7 +302,7 @@
* rendezvous points.
*/
int
-rend_service_introduce(circuit_t *circuit, char *request, int request_len)
+rend_service_introduce(circuit_t *circuit, const char *request, int request_len)
{
char *ptr, *rp_nickname, *r_cookie;
char buf[RELAY_PAYLOAD_SIZE];