[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Make tor build on windows again. More work still needed
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv14774/src/or
Modified Files:
buffers.c circuit.c connection.c connection_edge.c or.h
routerlist.c
Log Message:
Make tor build on windows again. More work still needed
Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/buffers.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- buffers.c 7 Mar 2004 23:50:15 -0000 1.68
+++ buffers.c 9 Mar 2004 22:01:16 -0000 1.69
@@ -433,7 +433,7 @@
log_fn(LOG_WARN,"socks5: offered methods don't include 'no auth'. Rejecting.");
req->replylen = 2; /* 2 bytes of response */
req->reply[0] = 5; /* socks5 reply */
- req->reply[1] = 0xFF; /* reject all methods */
+ req->reply[1] = '\xFF'; /* reject all methods */
return -1;
}
buf_remove_from_front(buf,2+nummethods);/* remove packet from buf */
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -d -r1.149 -r1.150
--- circuit.c 3 Mar 2004 04:11:18 -0000 1.149
+++ circuit.c 9 Mar 2004 22:01:16 -0000 1.150
@@ -6,7 +6,7 @@
extern or_options_t options; /* command-line and config-file options */
-static int relay_crypt(circuit_t *circ, cell_t *cell, char cell_direction,
+static int relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
crypt_path_t **layer_hint, char *recognized);
static connection_t *relay_lookup_conn(circuit_t *circ, cell_t *cell, int cell_direction);
static void circuit_free_cpath_node(crypt_path_t *victim);
@@ -488,7 +488,7 @@
}
/* wrap this into receive_relay_cell one day */
-static int relay_crypt(circuit_t *circ, cell_t *cell, char cell_direction,
+static int relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
crypt_path_t **layer_hint, char *recognized) {
crypt_path_t *thishop;
relay_header_t rh;
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -d -r1.176 -r1.177
--- connection.c 6 Mar 2004 01:43:37 -0000 1.176
+++ connection.c 9 Mar 2004 22:01:16 -0000 1.177
@@ -258,7 +258,7 @@
return -1;
}
- setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+ setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*) &one, sizeof(one));
if(bind(s,(struct sockaddr *)&bindaddr,sizeof(bindaddr)) < 0) {
log_fn(LOG_WARN,"Could not bind to port %u: %s",bindport,strerror(errno));
@@ -418,21 +418,24 @@
if(options.ORPort) {
listener_close_if_present(CONN_TYPE_OR_LISTENER);
- if(connection_create_listener(options.ORBindAddress, options.ORPort,
+ if(connection_create_listener(options.ORBindAddress,
+ (uint16_t) options.ORPort,
CONN_TYPE_OR_LISTENER) < 0)
return -1;
}
if(options.DirPort) {
listener_close_if_present(CONN_TYPE_DIR_LISTENER);
- if(connection_create_listener(options.DirBindAddress, options.DirPort,
+ if(connection_create_listener(options.DirBindAddress,
+ (uint16_t) options.DirPort,
CONN_TYPE_DIR_LISTENER) < 0)
return -1;
}
if(options.SocksPort) {
listener_close_if_present(CONN_TYPE_AP_LISTENER);
- if(connection_create_listener(options.SocksBindAddress, options.SocksPort,
+ if(connection_create_listener(options.SocksBindAddress,
+ (uint16_t) options.SocksPort,
CONN_TYPE_AP_LISTENER) < 0)
return -1;
}
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- connection_edge.c 7 Mar 2004 23:50:15 -0000 1.114
+++ connection_edge.c 9 Mar 2004 22:01:16 -0000 1.115
@@ -1003,7 +1003,7 @@
assert(address);
- if (inet_aton(address, &in)) {
+ if (tor_inet_aton(address, &in)) {
log_fn(LOG_DEBUG, "Using static address %s (%08lX)", address,
(unsigned long)ntohl(in.s_addr));
return ntohl(in.s_addr);
@@ -1039,7 +1039,7 @@
assert(address);
assert(val);
- if (inet_aton(address, &in))
+ if (tor_inet_aton(address, &in))
return;
search.address = (char*) address;
now = time(NULL);
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.246
retrieving revision 1.247
diff -u -d -r1.246 -r1.247
--- or.h 7 Mar 2004 23:50:15 -0000 1.246
+++ or.h 9 Mar 2004 22:01:16 -0000 1.247
@@ -84,7 +84,8 @@
#ifdef MS_WINDOWS
#include <io.h>
-#include <process.h>
+#include <process.h>
+#include <direct.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define snprintf _snprintf
@@ -349,7 +350,7 @@
* This is always in the range 0..1<<15-1.*/
/* bandwidth and receiver_bucket only used by ORs in OPEN state: */
- uint32_t bandwidth; /* connection bandwidth. */
+ int bandwidth; /* connection bandwidth. */
int receiver_bucket; /* when this hits 0, stop receiving. Every second we
* add 'bandwidth' to this, capping it at 10*bandwidth.
*/
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- routerlist.c 9 Mar 2004 14:53:00 -0000 1.33
+++ routerlist.c 9 Mar 2004 22:01:16 -0000 1.34
@@ -539,7 +539,37 @@
int router_exit_policy_rejects_all(routerinfo_t *router) {
return router_compare_addr_to_exit_policy(0, 0, router->exit_policy)
== ADDR_POLICY_REJECTED;
-}
+}
+
+static time_t parse_time(const char *cp)
+{
+ struct tm st_tm;
+ /* XXXX WWWW should be HAVE_STRPTIME */
+#ifndef MS_WINDOWS
+ if (!strptime(cp, "%Y-%m-%d %H:%M:%S", &st_tm)) {
+ log_fn(LOG_WARN, "Published time was unparseable"); return 0;
+ }
+#else
+ unsigned int year=0, month=0, day=0, hour=100, minute=100, second=100;
+ if (scanf("%u-%u-%u %u:%u:%u", cp, &year, &month,
+ &day, &hour, &minute, &second) < 6) {
+ log_fn(LOG_WARN, "Published time was unparseable"); return 0;
+ }
+ if (year < 2000 || month < 1 || month > 12 || day < 1 || day > 31 ||
+ hour > 24 || minute > 61 || second > 62) {
+ log_fn(LOG_WARN, "Published time was nonsensical"); return 0;
+ }
+ st_tm.tm_year = year;
+ st_tm.tm_mon = month;
+ st_tm.tm_mday = day;
+ st_tm.tm_hour = hour;
+ st_tm.tm_min = minute;
+ st_tm.tm_sec = second;
+#endif
+ return tor_timegm(&st_tm);
+
+}
+
/* Helper function: parse a directory from 's' and, when done, store the
* resulting routerlist in *dest, freeing the old value if necessary.
@@ -555,7 +585,6 @@
char signed_digest[128];
routerlist_t *new_dir = NULL;
char *versions = NULL;
- struct tm published;
time_t published_on;
char *good_nickname_lst[1024];
int n_good_nicknames = 0;
@@ -603,11 +632,10 @@
goto err;
}
assert(tok->n_args == 1);
-
- if (!strptime(tok->args[0], "%Y-%m-%d %H:%M:%S", &published)) {
- log_fn(LOG_WARN, "Published time was unparseable"); goto err;
+
+ if (!(published_on = parse_time(tok->args[0]))) {
+ goto err;
}
- published_on = tor_timegm(&published);
if (!(tok = find_first_by_keyword(tokens, K_RECOMMENDED_SOFTWARE))) {
log_fn(LOG_WARN, "Missing recommended-software line from directory.");
@@ -781,7 +809,6 @@
char digest[128];
smartlist_t *tokens = NULL, *exit_policy_tokens = NULL;
directory_token_t *tok;
- struct tm published;
int t, i;
int ports_set, bw_set;
@@ -875,12 +902,9 @@
if (!(tok = find_first_by_keyword(tokens, K_PUBLISHED))) {
log_fn(LOG_WARN, "Missing published time"); goto err;
}
- assert(tok->n_args == 1);
- if (!strptime(tok->args[0], "%Y-%m-%d %H:%M:%S", &published)) {
- log_fn(LOG_WARN, "Published time was unparseable"); goto err;
- }
- router->published_on = tor_timegm(&published);
-
+ assert(tok->n_args == 1);
+ if (!(router->published_on = parse_time(tok->args[0])))
+ goto err;
if (!(tok = find_first_by_keyword(tokens, K_ONION_KEY))) {
log_fn(LOG_WARN, "Missing onion key"); goto err;
@@ -1056,7 +1080,7 @@
if (strcmp(address, "*") == 0) {
newe->addr = 0;
- } else if (inet_aton(address, &in) != 0) {
+ } else if (tor_inet_aton(address, &in) != 0) {
newe->addr = ntohl(in.s_addr);
} else {
log_fn(LOG_WARN, "Malformed IP %s in exit policy; rejecting.",
@@ -1074,7 +1098,7 @@
if (!*endptr) {
/* strtol handled the whole mask. */
newe->msk = ~((1<<(32-bits))-1);
- } else if (inet_aton(mask, &in) != 0) {
+ } else if (tor_inet_aton(mask, &in) != 0) {
newe->msk = ntohl(in.s_addr);
} else {
log_fn(LOG_WARN, "Malformed mask %s on exit policy; rejecting.",
@@ -1087,11 +1111,11 @@
newe->prt_max = 65535;
} else {
endptr = NULL;
- newe->prt_min = strtol(port, &endptr, 10);
+ newe->prt_min = (uint16_t) strtol(port, &endptr, 10);
if (*endptr == '-') {
port = endptr+1;
endptr = NULL;
- newe->prt_max = strtol(port, &endptr, 10);
+ newe->prt_max = (uint16_t) strtol(port, &endptr, 10);
if (*endptr) {
log_fn(LOG_WARN, "Malformed port %s on exit policy; rejecting.",
port);