Changeset 484 for branches


Ignore:
Timestamp:
02/28/09 23:49:41 (3 years ago)
Author:
eagle
Message:

seems to work on WinXP now :)

Location:
branches/win/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/win/trunk/configure

    r482 r484  
    11#! /bin/sh 
    22# Guess values for system-dependent variables and create Makefiles. 
    3 # Generated by GNU Autoconf 2.63 for onioncat 0.1.10-480:481M. 
     3# Generated by GNU Autoconf 2.63 for onioncat 0.1.10-483M. 
    44# 
    55# Report bugs to <rahra@cypherpunk.at>. 
     
    597597PACKAGE_NAME='onioncat' 
    598598PACKAGE_TARNAME='onioncat' 
    599 PACKAGE_VERSION='0.1.10-480:481M' 
    600 PACKAGE_STRING='onioncat 0.1.10-480:481M' 
     599PACKAGE_VERSION='0.1.10-483M' 
     600PACKAGE_STRING='onioncat 0.1.10-483M' 
    601601PACKAGE_BUGREPORT='rahra@cypherpunk.at' 
    602602 
     
    12901290  # This message is too long to be a string in the A/UX 3.1 sh. 
    12911291  cat <<_ACEOF 
    1292 \`configure' configures onioncat 0.1.10-480:481M to adapt to many kinds of systems. 
     1292\`configure' configures onioncat 0.1.10-483M to adapt to many kinds of systems. 
    12931293 
    12941294Usage: $0 [OPTION]... [VAR=VALUE]... 
     
    13561356if test -n "$ac_init_help"; then 
    13571357  case $ac_init_help in 
    1358      short | recursive ) echo "Configuration of onioncat 0.1.10-480:481M:";; 
     1358     short | recursive ) echo "Configuration of onioncat 0.1.10-483M:";; 
    13591359   esac 
    13601360  cat <<\_ACEOF 
     
    14491449if $ac_init_version; then 
    14501450  cat <<\_ACEOF 
    1451 onioncat configure 0.1.10-480:481M 
     1451onioncat configure 0.1.10-483M 
    14521452generated by GNU Autoconf 2.63 
    14531453 
     
    14631463running configure, to aid debugging if configure makes a mistake. 
    14641464 
    1465 It was created by onioncat $as_me 0.1.10-480:481M, which was 
     1465It was created by onioncat $as_me 0.1.10-483M, which was 
    14661466generated by GNU Autoconf 2.63.  Invocation command line was 
    14671467 
     
    21792179# Define the identity of the package. 
    21802180 PACKAGE='onioncat' 
    2181  VERSION='0.1.10-480:481M' 
     2181 VERSION='0.1.10-483M' 
    21822182 
    21832183 
     
    23262326 
    23272327cat >>confdefs.h <<\_ACEOF 
    2328 #define SVN_REVISION "480:481M" 
     2328#define SVN_REVISION "483M" 
    23292329_ACEOF 
    23302330 
     
    56195619# values after options handling. 
    56205620ac_log=" 
    5621 This file was extended by onioncat $as_me 0.1.10-480:481M, which was 
     5621This file was extended by onioncat $as_me 0.1.10-483M, which was 
    56225622generated by GNU Autoconf 2.63.  Invocation command line was 
    56235623 
     
    56825682cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 
    56835683ac_cs_version="\\ 
    5684 onioncat config.status 0.1.10-480:481M 
     5684onioncat config.status 0.1.10-483M 
    56855685configured by $0, generated by GNU Autoconf 2.63, 
    56865686  with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" 
  • branches/win/trunk/src/ocat.c

    r482 r484  
    169169   log_msg(LOG_NOTICE, "waiting for system cleanup..."); 
    170170   // close tunnel interface 
     171#ifdef __CYGWIN__ 
     172   (void) win_close_tun(); 
     173#else 
    171174   log_debug("closing tunfd %d (and %d)", CNF(tunfd[0]), CNF(tunfd[1])); 
    172175   oe_close(CNF(tunfd[0])); 
    173176   if (CNF(tunfd[0]) != CNF(tunfd[1])) 
    174177      oe_close(CNF(tunfd[1])); 
     178#endif 
    175179 
    176180   // close and delete all peers 
     
    373377 
    374378#ifndef WITHOUT_TUN 
    375 #ifdef __CYGWIN__ 
    376    if (win_open_tun(CNF(tunname), sizeof(CNF(tunname))) == -1) 
    377    { 
    378       log_msg(LOG_ALERT, "opening TAP driver failed. exiting"); 
     379   // create TUN device 
     380   if ((CNF(tunfd[0]) = CNF(tunfd[1]) = tun_alloc(CNF(tunname), sizeof(CNF(tunname)), CNF(ocat_addr))) == -1) 
     381   { 
     382      log_msg(LOG_CRIT, "error opening TUN/TAP device"); 
    379383      exit(1); 
    380384   } 
    381 #else 
    382    // create TUN device 
    383    CNF(tunfd[0]) = CNF(tunfd[1]) = tun_alloc(CNF(tunname), CNF(ocat_addr)); 
    384 #endif 
    385385#endif 
    386386 
  • branches/win/trunk/src/ocat.h

    r482 r484  
    156156//! Standard buffer size 1024 bytes 
    157157#define SIZE_1K 1024 
     158#define SIZE_256 256 
    158159 
    159160#define DEQUEUER_WAKEUP 3 
     
    266267   char *tun_dev; 
    267268   //! tunnel interface name 
    268    char tunname[IFNAMSIZ]; 
     269   char tunname[SIZE_256]; 
    269270   int ipv4_enable; 
    270271   struct in_addr ocat_addr4; 
     
    501502/* ocattun.c */ 
    502503#ifndef WITHOUT_TUN 
    503 int tun_alloc(char *, struct in6_addr); 
     504int tun_alloc(char *, int, struct in6_addr); 
    504505#endif 
    505506 
     
    600601/* ocat_wintuntap.c */ 
    601602int win_open_tun(char *, int); 
     603int win_close_tun(void); 
    602604int win_read_tun(char *, int); 
    603605int win_write_tun(const char *, int); 
  • branches/win/trunk/src/ocat_wintuntap.c

    r483 r484  
    135135int win_open_tun(char *dev, int s) 
    136136{ 
    137    char deviceId[256], deviceName[256], tapPath[256]; 
     137   char deviceId[SIZE_256], deviceName[SIZE_256], tapPath[SIZE_256]; 
    138138   TapData_t *tapData = &tapData_; 
    139139   unsigned long len = 0; 
     
    183183   // % netsh interface ipv6 add route  fd87:d87e:eb43::/48 "LAN-Verbindung 2" 
    184184 
    185    strlcpy(dev, deviceId, s); 
     185   strlcpy(dev, deviceName, s); 
    186186   return 0; 
    187187} 
     
    202202int win_write_tun(const char *jb, int len) 
    203203{ 
    204     TapData_t *tapData = &tapData_; 
    205     DWORD written, err; 
    206     BOOL result; 
    207      
    208     result = GetOverlappedResult(tapData->fd, &tapData->write_overlapped, 
    209                                   &written, FALSE); 
    210  
    211     if (!result && GetLastError() == ERROR_IO_INCOMPLETE) 
    212         WaitForSingleObject(tapData->write_event, INFINITE); 
    213  
    214     if (!WriteFile(tapData->fd, jb, len, &written, &tapData->write_overlapped)) 
    215     { 
     204   TapData_t *tapData = &tapData_; 
     205   DWORD written, err; 
     206     
     207   log_debug("WriteFile %d bytes", len); 
     208   if (!GetOverlappedResult(tapData->fd, &tapData->write_overlapped, &written, FALSE)) 
     209   { 
     210      err = GetLastError(); 
     211      log_debug("GetOverlappedResult failed. Error = %ld", err); 
     212      if (err == ERROR_IO_INCOMPLETE) 
     213      { 
     214         log_debug("IO_COMPLETE, WaitForSingleObject"); 
     215         if ((err = WaitForSingleObject(tapData->write_event, INFINITE)) == WAIT_FAILED) 
     216            log_msg(LOG_ERR, "WaitForSingleObject failed. Error = %ld", GetLastError()); 
     217         else 
     218            log_debug("WaitForSingleObject returen %08lx", err); 
     219      } 
     220   } 
     221 
     222   if (!WriteFile(tapData->fd, jb, len, &written, &tapData->write_overlapped)) 
     223   { 
    216224      if ((err = GetLastError()) != ERROR_IO_PENDING) 
    217225      {    
    218        fprintf(stderr, "error writing %ld \n", err); 
    219        return -1; 
     226         log_msg(LOG_ERR, "error writing %ld", err); 
     227         return -1; 
    220228      } 
    221229      else 
    222          fprintf(stderr, "io pending\n"); 
    223     } 
    224  
    225     return written; 
    226      
     230         log_debug("IO_PENDING"); 
     231   } 
     232 
     233   return written; 
    227234} 
    228235 
     
    234241   DWORD len, err; 
    235242     
    236    log_debug("ReadFile"); 
     243   log_debug("ReadFile max. %d bytes", n); 
    237244   if (!ReadFile(tapData->fd, buf, n, &len, &tapData->read_overlapped)) 
    238245   { 
     
    240247      if ((err = GetLastError()) == ERROR_IO_PENDING) 
    241248      { 
    242          log_debug("ReadFile pending..."); 
    243  
    244          if ((err = WaitForSingleObject(tapData->read_event, INFINITE)) == WAIT_FAILED) 
    245             log_msg(LOG_ERR, "WaitForSingleObject failed. Error = %ld", GetLastError()); 
    246          else 
    247             log_debug("WaitForSingleObject returen %08lx", err); 
     249         for (err = WAIT_TIMEOUT; err == WAIT_TIMEOUT;) 
     250         { 
     251            log_debug("ReadFile pending..."); 
     252            if ((err = WaitForSingleObject(tapData->read_event, SELECT_TIMEOUT * 1000)) == WAIT_FAILED) 
     253               log_msg(LOG_ERR, "WaitForSingleObject failed. Error = %ld", GetLastError()); 
     254            log_debug("WaitForSingleObject returned %08lx", err); 
     255         } 
    248256 
    249257         if (!GetOverlappedResult(tapData->fd, &tapData->read_overlapped, &len, FALSE)) 
  • branches/win/trunk/src/ocateth.c

    r480 r484  
    282282   free_ckbuf(ckb); 
    283283 
     284#ifdef __CYGWIN__ 
     285   log_debug("writing %d bytes ndp solicitation to TAP driver", sizeof(buf) - 4); 
     286   // FIXME: there's no error checking 
     287   win_write_tun(buf + 4, sizeof(buf) - 4); 
     288#else 
    284289   log_debug("writing %d bytes ndp solicitation to tunfd %d", sizeof(buf), CNF(tunfd[1])); 
    285290   if (write(CNF(tunfd[1]), buf, sizeof(buf)) < sizeof(buf)) 
    286291      log_msg(LOG_ERR, "short write to tun fd %d", CNF(tunfd[1])); 
     292#endif 
    287293 
    288294   return 0; 
     
    377383   free_ckbuf(ckb); 
    378384 
     385#ifdef __CYGWIN__ 
     386   log_debug("writing %d bytes to TAP driver", rlen); 
     387   // FIXME: there's no error checking 
     388   win_write_tun(buf + 4, rlen - 4); 
     389#else 
    379390   log_debug("writing %d bytes to tunfd %d", rlen, CNF(tunfd[1])); 
    380391   if (write(CNF(tunfd[1]), buf, rlen) < rlen) 
    381392      log_msg(LOG_ERR, "short write"); 
     393#endif 
    382394 
    383395   return 0; 
  • branches/win/trunk/src/ocattun.c

    r433 r484  
    1 /* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger. 
     1/* Copyright 2008-2009 Bernhard R. Fischer. 
    22 * 
    33 * This file is part of OnionCat. 
     
    3333#define IFCBUF 1024 
    3434 
    35 int tun_alloc(char *dev, struct in6_addr addr) 
     35int tun_alloc(char *dev, int dev_s, struct in6_addr addr) 
    3636{ 
    3737   struct ifreq ifr; 
     
    4242   struct in_addr netmask = {CNF(ocat_addr4_mask)}; 
    4343 
     44   inet_ntop(AF_INET6, &addr, astr, INET6_ADDRSTRLEN); 
     45   inet_ntop(AF_INET, &CNF(ocat_addr4), astr4, INET_ADDRSTRLEN); 
     46 
     47#ifdef __CYGWIN__ 
     48   if ((fd = win_open_tun(dev, dev_s)) == -1) 
     49      return -1; 
     50 
     51      // set IPv6 address 
     52      // 181    // % netsh interface ipv6 add address "LAN-Verbindung 2" fd87:d87e:eb43:0:84:2100:0:8421 
     53      // 182    // add route 
     54      // 183    // % netsh interface ipv6 add route  fd87:d87e:eb43::/48 "LAN-Verbindung 2" 
     55 
     56   snprintf(buf, sizeof(buf), "netsh interface ipv6 add address \"%s\" %s", dev, astr); 
     57   log_debug("setting IP on tun: \"%s\"", buf); 
     58   if (system(buf) == -1) 
     59      log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno)); 
     60 
     61   snprintf(buf, sizeof(buf), "netsh interface ipv6 add route %s/%d \"%s\"", astr, TOR_PREFIX_LEN, dev); 
     62   log_debug("setting IP routing: \"%s\"", buf); 
     63   if (system(buf) == -1) 
     64      log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno)); 
     65 
     66   return 0; 
     67#endif 
     68 
    4469        log_debug("opening tun \"%s\"", tun_dev_); 
    4570   if ((fd = open(tun_dev_, O_RDWR)) < 0) 
    46       log_msg(LOG_EMERG, "could not open tundev %s: %s", tun_dev_, strerror(errno)), exit(1); 
    47    inet_ntop(AF_INET6, &addr, astr, INET6_ADDRSTRLEN); 
    48    inet_ntop(AF_INET, &CNF(ocat_addr4), astr4, INET_ADDRSTRLEN); 
     71   { 
     72      log_msg(LOG_EMERG, "could not open tundev %s: %s", tun_dev_, strerror(errno)); 
     73      return -1; 
     74   } 
    4975 
    5076#ifdef __linux__ 
     
    135161      log_msg(LOG_EMERG, "could not ioctl:TUNSIFHEAD: %s", strerror(errno)), exit(1); 
    136162 
    137 #endif 
     163#endif /* __linux__ */ 
    138164 
    139165 
     
    176202   if (CNF(use_tap)) 
    177203   { 
    178        snprintf(buf, sizeof(buf), "ifconfig %s up", dev); 
     204      snprintf(buf, sizeof(buf), "ifconfig %s up", dev); 
    179205      log_msg(LOG_INFO, "bringing up TAP device \"%s\"", buf); 
    180206      if (system(buf) == -1) 
     
    185211}               
    186212  
    187 #endif 
    188  
     213#endif /* WITHOUT_TUN */ 
     214 
Note: See TracChangeset for help on using the changeset viewer.