Changeset 484 for branches/win/trunk/src/ocattun.c
- Timestamp:
- 02/28/09 23:49:41 (3 years ago)
- File:
-
- 1 edited
-
branches/win/trunk/src/ocattun.c (modified) (6 diffs)
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. 2 2 * 3 3 * This file is part of OnionCat. … … 33 33 #define IFCBUF 1024 34 34 35 int tun_alloc(char *dev, struct in6_addr addr)35 int tun_alloc(char *dev, int dev_s, struct in6_addr addr) 36 36 { 37 37 struct ifreq ifr; … … 42 42 struct in_addr netmask = {CNF(ocat_addr4_mask)}; 43 43 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 44 69 log_debug("opening tun \"%s\"", tun_dev_); 45 70 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 } 49 75 50 76 #ifdef __linux__ … … 135 161 log_msg(LOG_EMERG, "could not ioctl:TUNSIFHEAD: %s", strerror(errno)), exit(1); 136 162 137 #endif 163 #endif /* __linux__ */ 138 164 139 165 … … 176 202 if (CNF(use_tap)) 177 203 { 178 snprintf(buf, sizeof(buf), "ifconfig %s up", dev);204 snprintf(buf, sizeof(buf), "ifconfig %s up", dev); 179 205 log_msg(LOG_INFO, "bringing up TAP device \"%s\"", buf); 180 206 if (system(buf) == -1) … … 185 211 } 186 212 187 #endif 188 213 #endif /* WITHOUT_TUN */ 214
Note: See TracChangeset
for help on using the changeset viewer.
