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

seems to work on WinXP now :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.