- Timestamp:
- 11/29/09 22:37:56 (2 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
- 2 copied
-
. (modified) (1 prop)
-
src (modified) (1 prop)
-
src/Makefile.am (modified) (1 diff)
-
src/Makefile.in (modified) (6 diffs)
-
src/cygwin/Makefile.in (modified) (1 diff)
-
src/ocat.c (modified) (11 diffs)
-
src/ocat.h (modified) (8 diffs)
-
src/ocat_netdesc.c (copied) (copied from branches/garlicat/src/ocat_netdesc.c)
-
src/ocat_netdesc.h (copied) (copied from branches/garlicat/src/ocat_netdesc.h)
-
src/ocatctrl.c (modified) (2 diffs)
-
src/ocatlibe.c (modified) (2 diffs)
-
src/ocatsetup.c (modified) (11 diffs)
-
src/ocatsocks.c (modified) (5 diffs)
-
src/ocattun.c (modified) (5 diffs)
-
src/ocatv6conv.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/garlicat (added) merged: 524-531
- Property svn:mergeinfo changed
-
trunk/src
- Property svn:mergeinfo changed
/branches/garlicat/src (added) merged: 525-529
- Property svn:mergeinfo changed
-
trunk/src/Makefile.am
r486 r534 1 1 bin_PROGRAMS = ocat 2 ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c 3 include_HEADERS = ocat.h strlcpy.c strlcat.c2 ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c ocat_netdesc.c 3 include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 4 4 5 install-exec-hook: 6 $(LN_S) -f $(DESTDIR)$(bindir)/ocat$(EXEEXT) \ 7 $(DESTDIR)$(bindir)/gcat$(EXEEXT) 8 -
trunk/src/Makefile.in
r508 r534 58 58 ocatipv4route.$(OBJEXT) ocateth.$(OBJEXT) ocatsocks.$(OBJEXT) \ 59 59 ocatlibe.$(OBJEXT) ocatctrl.$(OBJEXT) ocatipv6route.$(OBJEXT) \ 60 ocaticmp.$(OBJEXT) ocat_wintuntap.$(OBJEXT) 60 ocaticmp.$(OBJEXT) ocat_wintuntap.$(OBJEXT) \ 61 ocat_netdesc.$(OBJEXT) 61 62 ocat_OBJECTS = $(am_ocat_OBJECTS) 62 63 ocat_LDADD = $(LDADD) … … 107 108 LIBOBJS = @LIBOBJS@ 108 109 LIBS = @LIBS@ 110 LN_S = @LN_S@ 109 111 LTLIBOBJS = @LTLIBOBJS@ 110 112 MAKEINFO = @MAKEINFO@ … … 168 170 sysconfdir = @sysconfdir@ 169 171 target_alias = @target_alias@ 170 ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c 171 include_HEADERS = ocat.h strlcpy.c strlcat.c172 ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c ocat_netdesc.c 173 include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 172 174 all: all-am 173 175 … … 237 239 238 240 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocat.Po@am__quote@ 241 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocat_netdesc.Po@am__quote@ 239 242 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocat_wintuntap.Po@am__quote@ 240 243 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocatcompat.Po@am__quote@ … … 415 418 416 419 install-exec-am: install-binPROGRAMS 420 @$(NORMAL_INSTALL) 421 $(MAKE) $(AM_MAKEFLAGS) install-exec-hook 417 422 418 423 install-info: install-info-am … … 447 452 html-am info info-am install install-am install-binPROGRAMS \ 448 453 install-data install-data-am install-exec install-exec-am \ 449 install-includeHEADERS install-info install-info-am \ 450 install-man install-strip installcheck installcheck-am \ 451 installdirs maintainer-clean maintainer-clean-generic \ 452 mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ 453 ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \ 454 uninstall-includeHEADERS uninstall-info-am 455 454 install-exec-hook install-includeHEADERS install-info \ 455 install-info-am install-man install-strip installcheck \ 456 installcheck-am installdirs maintainer-clean \ 457 maintainer-clean-generic mostlyclean mostlyclean-compile \ 458 mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ 459 uninstall-am uninstall-binPROGRAMS uninstall-includeHEADERS \ 460 uninstall-info-am 461 462 463 install-exec-hook: 464 $(LN_S) -f $(DESTDIR)$(bindir)/ocat$(EXEEXT) \ 465 $(DESTDIR)$(bindir)/gcat$(EXEEXT) 456 466 # Tell versions [3.59,3.63) of GNU make to not export all variables. 457 467 # Otherwise a system limit (for SysV at least) may be exceeded. -
trunk/src/cygwin/Makefile.in
r508 r534 88 88 LIBOBJS = @LIBOBJS@ 89 89 LIBS = @LIBS@ 90 LN_S = @LN_S@ 90 91 LTLIBOBJS = @LTLIBOBJS@ 91 92 MAKEINFO = @MAKEINFO@ -
trunk/src/ocat.c
r523 r534 18 18 19 19 #include "ocat.h" 20 #include "ocat_netdesc.h" 20 21 21 22 … … 33 34 " -f <config_file> read config from config_file\n" 34 35 " -i convert onion hostname to IPv6 and exit\n" 36 " -I GarliCat mode, use I2P instead of Tor\n" 35 37 " -l [<ip>:]<port> set ocat listen address and port, default = 127.0.0.1:%d\n" 36 38 " -L <log_file> log output to <log_file> (default = stderr)\n" … … 51 53 OCAT_DIR, OCAT_CONNECT_LOG, CNF(create_clog), 52 54 CNF(daemon), CNF(daemon) ^ 1, 53 CNF(debug_level), OCAT_LISTEN_PORT,55 CNF(debug_level), NDESC(listen_port), 54 56 CNF(pid_file), 55 57 CNF(ocat_dest_port), ntohs(CNF(socks_dst)->sin_port), … … 237 239 int urlconv = 0; 238 240 239 snprintf(def, 100, "127.0.0.1:%d", OCAT_LISTEN_PORT);240 241 241 init_setup(); 242 242 243 if (argc < 2) 244 usage(argv[0]), exit(1); 245 246 while ((c = getopt(argc, argv, "abBCd:f:hrRiopl:t:T:s:u:4L:P:")) != -1) 243 while ((c = getopt(argc, argv, "abBCd:f:hrRiIopl:t:T:s:u:4L:P:")) != -1) 247 244 switch (c) 248 245 { … … 276 273 break; 277 274 275 case 'I': 276 CNF(net_type) = NTYPE_I2P; 277 break; 278 278 279 case 'l': 279 add_listener(optarg , def);280 add_listener(optarg); 280 281 break; 281 282 … … 340 341 exit(1); 341 342 } 343 344 // detect network type by command file name 345 // FIXME: this should be not hardcoded in that way 346 if (!strcmp(argv[0], "gcat") || !strcmp(argv[0], "garlicat")) 347 CNF(net_type) = NTYPE_I2P; 348 349 snprintf(def, 100, "127.0.0.1:%d", NDESC(listen_port)); 350 post_init_setup(); 351 352 // usage output must be after mode detection (Tor/I2P) 353 if (argc < 2) 354 usage(argv[0]), exit(1); 342 355 343 356 if (!CNF(rand_addr) && !argv[optind]) … … 367 380 log_msg(LOG_ERR, "address does not have TOR prefix"), exit(1); 368 381 ipv6tonion(&CNF(ocat_addr), CNF(onion_url)); 369 printf("%s .onion\n", CNF(onion_url));382 printf("%s%s\n", CNF(onion_url), NDESC(domain)); 370 383 exit(0); 371 384 } … … 373 386 // copy onion-URL from command line 374 387 if (!CNF(rand_addr)) 375 strncpy(CNF(onion_url), argv[optind], ONION_NAME_SIZE);388 strncpy(CNF(onion_url), argv[optind], NDESC(name_size)); 376 389 // ...or generate a random one 377 390 else … … 437 450 438 451 if (!CNF(oc_listen)) 439 add_listener(def , def);452 add_listener(def); 440 453 441 454 // start socket receiver thread … … 494 507 run_ocat_thread("controller", ocat_controller, NULL); 495 508 509 #ifdef CONNECT_ROOT_PEERS 496 510 // initiate connections to permanent root peers 497 511 log_debug("connecting root peers"); … … 499 513 if (!IN6_ARE_ADDR_EQUAL(&CNF(root_peer[c]), &CNF(ocat_addr))) 500 514 socks_queue(CNF(root_peer[c]), 1); 515 #endif 501 516 502 517 // reading config file -
trunk/src/ocat.h
r523 r534 102 102 103 103 #define IP6HLEN sizeof(struct ip6_hdr) 104 //! TOR prefix: FD87:D87E:EB43::/48105 #define TOR_PREFIX {{{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0,0,0,0,0,0,0,0,0,0}}}106 #define TOR_PREFIX_LEN 48107 #if BYTE_ORDER == LITTLE_ENDIAN108 #define TOR_PREFIX4 {0x0000000a}109 #define TOR_PREFIX4_MASK 0x000000ff110 #else111 #define TOR_PREFIX4 {0x0a000000}112 #define TOR_PREFIX4_MASK 0xff000000113 #endif114 104 //! Length of an .onion-URL (without ".onion" and '\0') 115 105 #define ONION_URL_LEN 16 116 //! Total length of .onion-URL117 #define ONION_NAME_SIZE (ONION_URL_LEN + 7)118 //! Total length of .onion-URL (equal to ONION_NAME_SIZE)119 #define ONION_NAME_LEN ONION_NAME_SIZE120 106 121 107 #define MAXPEERS 1024 122 //! Local listening port for incoming connections from TOR.123 #define OCAT_LISTEN_PORT 8060124 //! Local control port for querying status information.125 #define OCAT_CTRL_PORT 8066126 //! Virtual destination port for hidden services127 #define OCAT_DEST_PORT 8060128 //! SOCKS port of TOR proxy129 #define TOR_SOCKS_PORT 9050130 108 #ifdef __OpenBSD__ 131 109 #define OCAT_UNAME "_tor" … … 235 213 #define VERSION_STRING_LEN 256 236 214 237 typedef enum PeerType {PT_TOR, PT_I2P} PeerType_t; 215 216 #define NTYPE_TOR 0 217 #define NTYPE_I2P 1 218 238 219 239 220 struct OcatSetup … … 256 237 //! user name to change uid to 257 238 char *usrname; 258 char onion_url[ ONION_NAME_SIZE];239 char onion_url[SIZE_256]; 259 240 struct in6_addr ocat_addr; 260 241 //! flag to create connection log … … 282 263 int use_syslog; 283 264 int daemon; 265 #ifdef CONNECT_ROOT_PEERS 284 266 //! hardcoded permanent peers 285 267 #define ROOT_PEERS 1 286 268 struct in6_addr root_peer[ROOT_PEERS]; 269 #endif 287 270 time_t uptime; 288 271 char *frandn; … … 308 291 //! communication pipe for socks "selected" connector 309 292 int socksfd[2]; 293 int net_type; 310 294 }; 311 295 … … 359 343 unsigned inm; 360 344 unsigned outm; 361 PeerType_t type;362 345 } OcatPeer_t; 363 346 … … 566 549 void print_setup_struct(FILE *); 567 550 void init_setup(void); 551 void post_init_setup(void); 568 552 void lock_setup(void); 569 553 void unlock_setup(void); … … 599 583 int strsockaddr(const char *, struct sockaddr *); 600 584 void add_local_listeners(void); 601 void add_listener(const char * , const char *);585 void add_listener(const char *); 602 586 void delete_listeners(struct sockaddr **, int *, int); 603 587 int fdprintf(int, const char *, va_list); -
trunk/src/ocatctrl.c
r512 r534 25 25 26 26 #include "ocat.h" 27 #include "ocat_netdesc.h" 27 28 28 29 … … 37 38 int fd, c; 38 39 FILE *ff, *fo; 39 char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[ ONION_NAME_SIZE], timestr[32], *s, *tokbuf;40 char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[NDESC(name_size)], timestr[32], *s, *tokbuf; 40 41 int rlen, cfd; 41 42 struct tm *tm; -
trunk/src/ocatlibe.c
r500 r534 138 138 139 139 140 void add_listener(const char *buf, const char *def) 141 { 140 void add_listener(const char *buf) 141 { 142 struct sockaddr_in6 saddr; 143 144 if (strsockaddr(buf, &saddr) == -1) 145 log_msg(LOG_EMERG, "could not convert address string '%s'", buf), exit(1); 146 142 147 CNF(oc_listen_cnt)++; 143 148 log_debug("reallocating sockaddr list to %d elements", CNF(oc_listen_cnt)); … … 147 152 log_msg(LOG_ERR, "could not get memory for listener fds: \"%s\"", strerror(errno)), exit(1); 148 153 149 log_debug("allocating sockaddr mem for \"%s\"", def);154 log_debug("allocating sockaddr mem for \"%s\"", buf); 150 155 if (!(CNF(oc_listen)[CNF(oc_listen_cnt) - 1] = calloc(1, sizeof(struct sockaddr_in6)))) 151 156 log_msg(LOG_ERR, "could not get memory for listener : \"%s\"", strerror(errno)), exit(1); 152 157 153 158 CNF(oc_listen_fd)[CNF(oc_listen_cnt) - 1] = -1; 154 155 if (def) 156 if (strsockaddr(def, CNF(oc_listen)[CNF(oc_listen_cnt) - 1]) == -1) 157 log_msg(LOG_EMERG, "illegal default string '%s'", def), exit(1); 158 159 if (strsockaddr(buf, CNF(oc_listen)[CNF(oc_listen_cnt) - 1]) == -1) 160 log_msg(LOG_EMERG, "could not convert address string '%s'", buf), exit(1); 159 memcpy(CNF(oc_listen)[CNF(oc_listen_cnt) - 1], &saddr, sizeof(saddr)); 161 160 } 162 161 -
trunk/src/ocatsetup.c
r514 r534 25 25 26 26 #include "ocat.h" 27 #include "ocat_netdesc.h" 27 28 28 29 … … 46 47 //TOR_SOCKS_PORT, 47 48 //OCAT_LISTEN_PORT, 48 OCAT_DEST_PORT, OCAT_CTRL_PORT,49 0, 0, 49 50 //! default tunfd is stdin/stdout 50 51 {0, 1}, … … 53 54 OCAT_UNAME, {0}, {{{0}}}, 0, 0, 1, OCAT_DIR, TUN_DEV, 54 55 {'\0'}, // tunname 55 0, TOR_PREFIX4, TOR_PREFIX4_MASK, 56 0, 57 //ADDR4_PREFIX, ADDR4_MASK 58 {0}, 0, 56 59 NULL, 1, 57 60 #ifdef __CYGWIN__ … … 70 73 1, // daemon 71 74 #endif 75 #ifdef CONNECT_ROOT_PEERS 72 76 { 73 77 /* … … 78 82 0xf6, 0x83, 0x64, 0xac, 0x73, 0xf9, 0x61, 0xac, 0x9a, 0x00}}} // initial permanent peer "62bwjldt7fq2zgqa" (dot.cat) 79 83 }, 84 #endif 80 85 0, 81 86 "/dev/urandom", … … 106 111 , 107 112 // socksfd 108 {-1, -1} 113 {-1, -1}, 114 // net_type 115 NTYPE_TOR 109 116 }; 110 117 … … 124 131 //setup_.logf = stderr; 125 132 setup_.uptime = time(NULL); 133 } 134 135 136 void post_init_setup(void) 137 { 138 setup_.ocat_addr4 = NDESC(prefix4); 139 setup_.ocat_addr4_mask = NDESC(addr4_mask); 140 setup_.ocat_dest_port = NDESC(vdest_port); 141 setup_.ocat_ctrl_port = NDESC(ctrl_port); 126 142 127 143 setup_.socks_dst->sin_family = AF_INET; 128 setup_.socks_dst->sin_port = htons( TOR_SOCKS_PORT);144 setup_.socks_dst->sin_port = htons(NDESC(socks_port)); 129 145 setup_.socks_dst->sin_addr.s_addr = htonl(INADDR_LOOPBACK); 130 146 #ifdef HAVE_SIN_LEN 131 147 setup_.socks_dst->sin_len = SOCKADDR_SIZE(setup_.socks_dst); 132 #endif133 134 #ifdef DEBUG135 snprintf(setup_.version, VERSION_STRING_LEN, "%s (c) %s -- compiled %s %s", PACKAGE_STRING, OCAT_AUTHOR, __DATE__, __TIME__);136 #else137 snprintf(setup_.version, VERSION_STRING_LEN, "%s (c) %s", PACKAGE_STRING, OCAT_AUTHOR);138 148 #endif 139 149 … … 152 162 #endif 153 163 164 snprintf(setup_.version, VERSION_STRING_LEN, "%s (c) %s (%s mode)", PACKAGE_STRING, OCAT_AUTHOR, setup_.net_type == NTYPE_TOR ? "OnionCat" : setup_.net_type == NTYPE_I2P ? "GarliCat" : "unknown"); 165 #ifdef DEBUG 166 snprintf(&setup_.version[strlen(setup_.version)], VERSION_STRING_LEN - strlen(setup_.version), " -- compiled %s %s", __DATE__, __TIME__); 167 #endif 154 168 } 155 169 … … 160 174 void print_setup_struct(FILE *f) 161 175 { 162 char *c, ip[SBUF], nm[SBUF], ip6[SBUF], logf[SBUF], hw[SBUF] , rp[SBUF];176 char *c, ip[SBUF], nm[SBUF], ip6[SBUF], logf[SBUF], hw[SBUF]; 163 177 int i, t; 164 178 struct sockaddr_str sas; … … 212 226 "sizeof_setup = %d\n" 213 227 "term_req = %d\n" 228 "net_type = %d (%s)\n" 214 229 , 215 230 IPV4_KEY, ntohl(setup_.fhd_key[IPV4_KEY]), IPV6_KEY, ntohl(setup_.fhd_key[IPV6_KEY]), … … 244 259 (int) strlen(setup_.version), VERSION_STRING_LEN, setup_.version, 245 260 setup_.sizeof_setup, 246 setup_.term_req 261 setup_.term_req, 262 setup_.net_type, setup_.net_type == NTYPE_TOR ? "NTYPE_TOR" : setup_.net_type == NTYPE_I2P ? "NTYPE_I2P" : "unknown" 247 263 ); 248 264 265 #ifdef CONNECT_ROOT_PEERS 249 266 for (i = 0; i < ROOT_PEERS; i++) 250 if (inet_ntop(AF_INET6, &setup_.root_peer[i], rp, SBUF)) 251 fprintf(f, "root_peer[%d] = %s\n", i, rp); 267 if (inet_ntop(AF_INET6, &setup_.root_peer[i], ip6, SBUF)) 268 fprintf(f, "root_peer[%d] = %s\n", i, ip6); 269 #endif 252 270 253 271 if (inet_ntops((struct sockaddr*) setup_.socks_dst, &sas)) -
trunk/src/ocatsocks.c
r508 r534 26 26 27 27 #include "ocat.h" 28 #include "ocat_netdesc.h" 28 29 29 30 … … 31 32 static SocksQueue_t *socks_queue_ = NULL; 32 33 33 #define SOCKS_BUFLEN (sizeof(SocksHdr_t) + ONION_NAME_SIZE+ strlen(CNF(usrname)) + 2)34 #define SOCKS_BUFLEN (sizeof(SocksHdr_t) + NDESC(name_size) + strlen(CNF(usrname)) + 2) 34 35 35 36 … … 37 38 { 38 39 int len, ret; 39 char buf[SOCKS_BUFLEN], onion[ ONION_NAME_SIZE];40 char buf[SOCKS_BUFLEN], onion[NDESC(name_size)]; 40 41 SocksHdr_t *shdr = (SocksHdr_t*) buf; 41 42 42 43 ipv6tonion(&sq->addr, onion); 43 strlcat(onion, ".onion", sizeof(onion));44 strlcat(onion, NDESC(domain), sizeof(onion)); 44 45 log_msg(LOG_INFO, "trying to connect to \"%s\" [%s]", onion, inet_ntop(AF_INET6, &sq->addr, buf, SOCKS_BUFLEN)); 45 46 … … 246 247 { 247 248 int i; 248 char addrstr[INET6_ADDRSTRLEN], onstr[ ONION_NAME_LEN], buf[SIZE_1K];249 char addrstr[INET6_ADDRSTRLEN], onstr[NDESC(name_size)], buf[SIZE_1K]; 249 250 SocksQueue_t *squeue; 250 251 … … 257 258 } 258 259 259 snprintf(buf, SIZE_1K, "%d: %39s, %s .onion, state = %d, %s(%d), retry = %d, connect_time = %d, restart_time = %d",260 snprintf(buf, SIZE_1K, "%d: %39s, %s%s, state = %d, %s(%d), retry = %d, connect_time = %d, restart_time = %d", 260 261 i, 261 262 addrstr, 262 263 ipv6tonion(&squeue->addr, onstr), 264 NDESC(domain), 263 265 squeue->state, 264 266 squeue->perm ? "PERMANENT" : "TEMPORARY", -
trunk/src/ocattun.c
r511 r534 27 27 28 28 #include "ocat.h" 29 #include "ocat_netdesc.h" 29 30 30 31 … … 61 62 log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno)); 62 63 63 snprintf(buf, sizeof(buf), "netsh interface ipv6 add route %s/%d \"%s\"", astr, TOR_PREFIX_LEN, dev);64 snprintf(buf, sizeof(buf), "netsh interface ipv6 add route %s/%d \"%s\"", astr, NDESC(prefix_len), dev); 64 65 log_debug("setting IP routing: \"%s\"", buf); 65 66 if (system(buf) == -1) … … 92 93 if (!CNF(use_tap)) 93 94 { 94 snprintf(buf, sizeof(buf), "ifconfig %s add %s/%d up", dev, astr, TOR_PREFIX_LEN);95 snprintf(buf, sizeof(buf), "ifconfig %s add %s/%d up", dev, astr, NDESC(prefix_len)); 95 96 log_msg(LOG_INFO, "configuring tun IP: \"%s\"", buf); 96 97 if (system(buf) == -1) … … 169 170 { 170 171 #ifdef __OpenBSD__ 171 snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s prefixlen %d up", dev, astr, TOR_PREFIX_LEN);172 snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s prefixlen %d up", dev, astr, NDESC(prefix_len)); 172 173 #else 173 snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s/%d up", dev, astr, TOR_PREFIX_LEN);174 snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s/%d up", dev, astr, NDESC(prefix_len)); 174 175 #endif 175 176 log_debug("setting IP on tun: \"%s\"", buf); … … 181 182 // MacOSX requires the route to be set up manually 182 183 // FIXME: the prefix shouldn't be hardcoded here 183 snprintf(buf, sizeof(buf), "route add -inet6 -net fd87:d87e:eb43:: -prefixlen %d -gateway %s", TOR_PREFIX_LEN, astr);184 snprintf(buf, sizeof(buf), "route add -inet6 -net fd87:d87e:eb43:: -prefixlen %d -gateway %s", NDESC(prefix_len), astr); 184 185 log_msg(LOG_INFO, "setup routing: \"%s\"", buf); 185 186 if (system(buf) == -1) -
trunk/src/ocatv6conv.c
r500 r534 27 27 28 28 #include "ocat.h" 29 #include "ocat_netdesc.h" 29 30 30 31 static const char BASE32[] = "abcdefghijklmnopqrstuvwxyz234567"; … … 40 41 50 51 52 53 54 55 56 57 58 59 5a */ 41 42 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }; 42 static const struct in6_addr tor_prefix_ = TOR_PREFIX;43 43 44 44 45 45 int has_tor_prefix(const struct in6_addr *addr) 46 46 { 47 return memcmp(addr, & tor_prefix_, 6) == 0;47 return memcmp(addr, &NDESC(prefix), 6) == 0; 48 48 } 49 49 … … 51 51 void set_tor_prefix(struct in6_addr *addr) 52 52 { 53 memcpy(addr, & tor_prefix_, 6);53 memcpy(addr, &NDESC(prefix), 6); 54 54 } 55 55
Note: See TracChangeset
for help on using the changeset viewer.
