Changeset 534 for trunk/src


Ignore:
Timestamp:
11/29/09 22:37:56 (2 years ago)
Author:
eagle
Message:

merged GarliCat branch back into trunk
onioncat-privatehosts.pl added (code by zzz)

Location:
trunk
Files:
13 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src

  • trunk/src/Makefile.am

    r486 r534  
    11bin_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.c 
     2ocat_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 
     3include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 
    44 
     5install-exec-hook: 
     6        $(LN_S) -f $(DESTDIR)$(bindir)/ocat$(EXEEXT) \ 
     7        $(DESTDIR)$(bindir)/gcat$(EXEEXT) 
     8 
  • trunk/src/Makefile.in

    r508 r534  
    5858        ocatipv4route.$(OBJEXT) ocateth.$(OBJEXT) ocatsocks.$(OBJEXT) \ 
    5959        ocatlibe.$(OBJEXT) ocatctrl.$(OBJEXT) ocatipv6route.$(OBJEXT) \ 
    60         ocaticmp.$(OBJEXT) ocat_wintuntap.$(OBJEXT) 
     60        ocaticmp.$(OBJEXT) ocat_wintuntap.$(OBJEXT) \ 
     61        ocat_netdesc.$(OBJEXT) 
    6162ocat_OBJECTS = $(am_ocat_OBJECTS) 
    6263ocat_LDADD = $(LDADD) 
     
    107108LIBOBJS = @LIBOBJS@ 
    108109LIBS = @LIBS@ 
     110LN_S = @LN_S@ 
    109111LTLIBOBJS = @LTLIBOBJS@ 
    110112MAKEINFO = @MAKEINFO@ 
     
    168170sysconfdir = @sysconfdir@ 
    169171target_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.c 
     172ocat_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 
     173include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 
    172174all: all-am 
    173175 
     
    237239 
    238240@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocat.Po@am__quote@ 
     241@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocat_netdesc.Po@am__quote@ 
    239242@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocat_wintuntap.Po@am__quote@ 
    240243@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocatcompat.Po@am__quote@ 
     
    415418 
    416419install-exec-am: install-binPROGRAMS 
     420        @$(NORMAL_INSTALL) 
     421        $(MAKE) $(AM_MAKEFLAGS) install-exec-hook 
    417422 
    418423install-info: install-info-am 
     
    447452        html-am info info-am install install-am install-binPROGRAMS \ 
    448453        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 
     463install-exec-hook: 
     464        $(LN_S) -f $(DESTDIR)$(bindir)/ocat$(EXEEXT) \ 
     465        $(DESTDIR)$(bindir)/gcat$(EXEEXT) 
    456466# Tell versions [3.59,3.63) of GNU make to not export all variables. 
    457467# Otherwise a system limit (for SysV at least) may be exceeded. 
  • trunk/src/cygwin/Makefile.in

    r508 r534  
    8888LIBOBJS = @LIBOBJS@ 
    8989LIBS = @LIBS@ 
     90LN_S = @LN_S@ 
    9091LTLIBOBJS = @LTLIBOBJS@ 
    9192MAKEINFO = @MAKEINFO@ 
  • trunk/src/ocat.c

    r523 r534  
    1818 
    1919#include "ocat.h" 
     20#include "ocat_netdesc.h" 
    2021 
    2122 
     
    3334         "   -f <config_file>      read config from config_file\n" 
    3435         "   -i                    convert onion hostname to IPv6 and exit\n" 
     36         "   -I                    GarliCat mode, use I2P instead of Tor\n" 
    3537         "   -l [<ip>:]<port>      set ocat listen address and port, default = 127.0.0.1:%d\n" 
    3638         "   -L <log_file>         log output to <log_file> (default = stderr)\n" 
     
    5153         OCAT_DIR, OCAT_CONNECT_LOG, CNF(create_clog),  
    5254         CNF(daemon), CNF(daemon) ^ 1, 
    53          CNF(debug_level), OCAT_LISTEN_PORT, 
     55         CNF(debug_level), NDESC(listen_port), 
    5456         CNF(pid_file), 
    5557         CNF(ocat_dest_port), ntohs(CNF(socks_dst)->sin_port),  
     
    237239   int urlconv = 0; 
    238240 
    239    snprintf(def, 100, "127.0.0.1:%d", OCAT_LISTEN_PORT); 
    240  
    241241   init_setup(); 
    242242 
    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) 
    247244      switch (c) 
    248245      { 
     
    276273            break; 
    277274 
     275         case 'I': 
     276            CNF(net_type) = NTYPE_I2P; 
     277            break; 
     278 
    278279         case 'l': 
    279             add_listener(optarg, def); 
     280            add_listener(optarg); 
    280281            break; 
    281282 
     
    340341            exit(1); 
    341342      } 
     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); 
    342355 
    343356   if (!CNF(rand_addr) && !argv[optind]) 
     
    367380         log_msg(LOG_ERR, "address does not have TOR prefix"), exit(1); 
    368381      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)); 
    370383      exit(0); 
    371384   } 
     
    373386   // copy onion-URL from command line 
    374387   if (!CNF(rand_addr)) 
    375       strncpy(CNF(onion_url), argv[optind], ONION_NAME_SIZE); 
     388      strncpy(CNF(onion_url), argv[optind], NDESC(name_size)); 
    376389   // ...or generate a random one 
    377390   else 
     
    437450 
    438451   if (!CNF(oc_listen)) 
    439       add_listener(def, def); 
     452      add_listener(def); 
    440453 
    441454   // start socket receiver thread 
     
    494507      run_ocat_thread("controller", ocat_controller, NULL); 
    495508 
     509#ifdef CONNECT_ROOT_PEERS 
    496510   // initiate connections to permanent root peers 
    497511   log_debug("connecting root peers"); 
     
    499513      if (!IN6_ARE_ADDR_EQUAL(&CNF(root_peer[c]), &CNF(ocat_addr))) 
    500514         socks_queue(CNF(root_peer[c]), 1); 
     515#endif 
    501516 
    502517   // reading config file 
  • trunk/src/ocat.h

    r523 r534  
    102102 
    103103#define IP6HLEN sizeof(struct ip6_hdr) 
    104 //! TOR prefix: FD87:D87E:EB43::/48 
    105 #define TOR_PREFIX {{{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0,0,0,0,0,0,0,0,0,0}}} 
    106 #define TOR_PREFIX_LEN 48 
    107 #if BYTE_ORDER == LITTLE_ENDIAN 
    108 #define TOR_PREFIX4 {0x0000000a} 
    109 #define TOR_PREFIX4_MASK 0x000000ff 
    110 #else 
    111 #define TOR_PREFIX4 {0x0a000000} 
    112 #define TOR_PREFIX4_MASK 0xff000000 
    113 #endif 
    114104//! Length of an .onion-URL (without ".onion" and '\0') 
    115105#define ONION_URL_LEN 16 
    116 //! Total length of .onion-URL 
    117 #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_SIZE 
    120106 
    121107#define MAXPEERS 1024 
    122 //! Local listening port for incoming connections from TOR. 
    123 #define OCAT_LISTEN_PORT 8060 
    124 //! Local control port for querying status information. 
    125 #define OCAT_CTRL_PORT 8066 
    126 //! Virtual destination port for hidden services 
    127 #define OCAT_DEST_PORT 8060 
    128 //! SOCKS port of TOR proxy 
    129 #define TOR_SOCKS_PORT 9050 
    130108#ifdef __OpenBSD__ 
    131109#define OCAT_UNAME "_tor" 
     
    235213#define VERSION_STRING_LEN 256 
    236214 
    237 typedef enum PeerType {PT_TOR, PT_I2P} PeerType_t; 
     215 
     216#define NTYPE_TOR 0 
     217#define NTYPE_I2P 1 
     218 
    238219 
    239220struct OcatSetup 
     
    256237   //! user name to change uid to 
    257238   char *usrname; 
    258    char onion_url[ONION_NAME_SIZE]; 
     239   char onion_url[SIZE_256]; 
    259240   struct in6_addr ocat_addr; 
    260241   //! flag to create connection log 
     
    282263   int use_syslog; 
    283264   int daemon; 
     265#ifdef CONNECT_ROOT_PEERS 
    284266   //! hardcoded permanent peers 
    285267#define ROOT_PEERS 1 
    286268   struct in6_addr root_peer[ROOT_PEERS]; 
     269#endif 
    287270   time_t uptime; 
    288271   char *frandn; 
     
    308291   //! communication pipe for socks "selected" connector 
    309292   int socksfd[2]; 
     293   int net_type; 
    310294}; 
    311295 
     
    359343   unsigned inm; 
    360344   unsigned outm; 
    361    PeerType_t type; 
    362345} OcatPeer_t; 
    363346 
     
    566549void print_setup_struct(FILE *); 
    567550void init_setup(void); 
     551void post_init_setup(void); 
    568552void lock_setup(void); 
    569553void unlock_setup(void); 
     
    599583int strsockaddr(const char *, struct sockaddr *); 
    600584void add_local_listeners(void); 
    601 void add_listener(const char *, const char *); 
     585void add_listener(const char *); 
    602586void delete_listeners(struct sockaddr **, int *, int); 
    603587int fdprintf(int, const char *, va_list); 
  • trunk/src/ocatctrl.c

    r512 r534  
    2525 
    2626#include "ocat.h" 
     27#include "ocat_netdesc.h" 
    2728 
    2829 
     
    3738   int fd, c; 
    3839   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; 
    4041   int rlen, cfd; 
    4142   struct tm *tm; 
  • trunk/src/ocatlibe.c

    r500 r534  
    138138 
    139139 
    140 void add_listener(const char *buf, const char *def) 
    141 { 
     140void 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 
    142147   CNF(oc_listen_cnt)++; 
    143148   log_debug("reallocating sockaddr list to %d elements", CNF(oc_listen_cnt)); 
     
    147152      log_msg(LOG_ERR, "could not get memory for listener fds: \"%s\"", strerror(errno)), exit(1); 
    148153 
    149    log_debug("allocating sockaddr mem for \"%s\"", def); 
     154   log_debug("allocating sockaddr mem for \"%s\"", buf); 
    150155   if (!(CNF(oc_listen)[CNF(oc_listen_cnt) - 1] = calloc(1, sizeof(struct sockaddr_in6)))) 
    151156      log_msg(LOG_ERR, "could not get memory for listener : \"%s\"", strerror(errno)), exit(1); 
    152157 
    153158   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)); 
    161160} 
    162161 
  • trunk/src/ocatsetup.c

    r514 r534  
    2525 
    2626#include "ocat.h" 
     27#include "ocat_netdesc.h" 
    2728 
    2829 
     
    4647   //TOR_SOCKS_PORT,  
    4748   //OCAT_LISTEN_PORT,  
    48    OCAT_DEST_PORT, OCAT_CTRL_PORT,  
     49   0, 0, 
    4950   //! default tunfd is stdin/stdout 
    5051   {0, 1}, 
     
    5354   OCAT_UNAME, {0}, {{{0}}}, 0, 0, 1, OCAT_DIR, TUN_DEV, 
    5455   {'\0'},                                // tunname 
    55    0, TOR_PREFIX4, TOR_PREFIX4_MASK, 
     56   0,  
     57   //ADDR4_PREFIX, ADDR4_MASK 
     58   {0}, 0, 
    5659   NULL, 1, 
    5760#ifdef __CYGWIN__ 
     
    7073   1,                                      // daemon 
    7174#endif 
     75#ifdef CONNECT_ROOT_PEERS 
    7276   { 
    7377      /* 
     
    7882           0xf6, 0x83, 0x64, 0xac, 0x73, 0xf9, 0x61, 0xac, 0x9a, 0x00}}}  // initial permanent peer "62bwjldt7fq2zgqa" (dot.cat) 
    7983   }, 
     84#endif 
    8085   0, 
    8186   "/dev/urandom", 
     
    106111   , 
    107112   // socksfd 
    108    {-1, -1} 
     113   {-1, -1}, 
     114   // net_type 
     115   NTYPE_TOR 
    109116}; 
    110117 
     
    124131   //setup_.logf = stderr; 
    125132   setup_.uptime = time(NULL); 
     133} 
     134 
     135 
     136void 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); 
    126142 
    127143   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)); 
    129145   setup_.socks_dst->sin_addr.s_addr = htonl(INADDR_LOOPBACK); 
    130146#ifdef HAVE_SIN_LEN 
    131147   setup_.socks_dst->sin_len = SOCKADDR_SIZE(setup_.socks_dst); 
    132 #endif 
    133  
    134 #ifdef DEBUG 
    135    snprintf(setup_.version, VERSION_STRING_LEN, "%s (c) %s -- compiled %s %s", PACKAGE_STRING, OCAT_AUTHOR, __DATE__, __TIME__); 
    136 #else 
    137    snprintf(setup_.version, VERSION_STRING_LEN, "%s (c) %s", PACKAGE_STRING, OCAT_AUTHOR); 
    138148#endif 
    139149 
     
    152162#endif 
    153163 
     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 
    154168} 
    155169 
     
    160174void print_setup_struct(FILE *f) 
    161175{ 
    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]; 
    163177   int i, t; 
    164178   struct sockaddr_str sas; 
     
    212226         "sizeof_setup           = %d\n" 
    213227         "term_req               = %d\n" 
     228         "net_type               = %d (%s)\n" 
    214229         , 
    215230         IPV4_KEY, ntohl(setup_.fhd_key[IPV4_KEY]), IPV6_KEY, ntohl(setup_.fhd_key[IPV6_KEY]), 
     
    244259         (int) strlen(setup_.version), VERSION_STRING_LEN, setup_.version, 
    245260         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" 
    247263         ); 
    248264 
     265#ifdef CONNECT_ROOT_PEERS 
    249266   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 
    252270 
    253271   if (inet_ntops((struct sockaddr*) setup_.socks_dst, &sas)) 
  • trunk/src/ocatsocks.c

    r508 r534  
    2626 
    2727#include "ocat.h" 
     28#include "ocat_netdesc.h" 
    2829 
    2930 
     
    3132static SocksQueue_t *socks_queue_ = NULL; 
    3233 
    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) 
    3435 
    3536 
     
    3738{ 
    3839   int len, ret; 
    39    char buf[SOCKS_BUFLEN], onion[ONION_NAME_SIZE]; 
     40   char buf[SOCKS_BUFLEN], onion[NDESC(name_size)]; 
    4041   SocksHdr_t *shdr = (SocksHdr_t*) buf; 
    4142 
    4243   ipv6tonion(&sq->addr, onion); 
    43    strlcat(onion, ".onion", sizeof(onion)); 
     44   strlcat(onion, NDESC(domain), sizeof(onion)); 
    4445   log_msg(LOG_INFO, "trying to connect to \"%s\" [%s]", onion, inet_ntop(AF_INET6, &sq->addr, buf, SOCKS_BUFLEN)); 
    4546 
     
    246247{ 
    247248   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]; 
    249250   SocksQueue_t *squeue; 
    250251 
     
    257258      } 
    258259 
    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", 
    260261            i,  
    261262            addrstr,  
    262263            ipv6tonion(&squeue->addr, onstr), 
     264            NDESC(domain), 
    263265            squeue->state, 
    264266            squeue->perm ? "PERMANENT" : "TEMPORARY", 
  • trunk/src/ocattun.c

    r511 r534  
    2727 
    2828#include "ocat.h" 
     29#include "ocat_netdesc.h" 
    2930 
    3031 
     
    6162      log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno)); 
    6263 
    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); 
    6465   log_debug("setting IP routing: \"%s\"", buf); 
    6566   if (system(buf) == -1) 
     
    9293   if (!CNF(use_tap)) 
    9394   { 
    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)); 
    9596      log_msg(LOG_INFO, "configuring tun IP: \"%s\"", buf); 
    9697      if (system(buf) == -1) 
     
    169170   { 
    170171#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)); 
    172173#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)); 
    174175#endif 
    175176      log_debug("setting IP on tun: \"%s\"", buf); 
     
    181182      // MacOSX requires the route to be set up manually 
    182183      // 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); 
    184185      log_msg(LOG_INFO, "setup routing: \"%s\"", buf); 
    185186      if (system(buf) == -1) 
  • trunk/src/ocatv6conv.c

    r500 r534  
    2727 
    2828#include "ocat.h" 
     29#include "ocat_netdesc.h" 
    2930 
    3031static const char BASE32[] = "abcdefghijklmnopqrstuvwxyz234567"; 
     
    4041      50  51  52  53  54  55  56  57  58  59  5a */ 
    4142      15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 };   
    42 static const struct in6_addr tor_prefix_ = TOR_PREFIX; 
    4343 
    4444 
    4545int has_tor_prefix(const struct in6_addr *addr) 
    4646{ 
    47    return memcmp(addr, &tor_prefix_, 6) == 0; 
     47   return memcmp(addr, &NDESC(prefix), 6) == 0; 
    4848} 
    4949 
     
    5151void set_tor_prefix(struct in6_addr *addr) 
    5252{ 
    53    memcpy(addr, &tor_prefix_, 6); 
     53   memcpy(addr, &NDESC(prefix), 6); 
    5454} 
    5555 
Note: See TracChangeset for help on using the changeset viewer.