From 05064b327eee494f40bf2c77e9865dfe620d885f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Sch=C3=B6ller?= <hans@schoeller.se> Date: Sat, 8 Aug 2009 17:20:56 +0200 Subject: [PATCH] fixed ip assignment, v0.3.1 --- main.cpp | 2 +- tun.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 2728443..ca38256 100644 --- a/main.cpp +++ b/main.cpp @@ -34,7 +34,7 @@ void usage() { printf( - "Hans - IP over ICMP version 0.3\n\n" + "Hans - IP over ICMP version 0.3.1\n\n" "RUN AS SERVER\n" " hans -s network [-fvr] [-p password] [-u unprivileged_user] [-d tun_device] [-m reference_mtu]\n\n" "RUN AS CLIENT\n" diff --git a/tun.cpp b/tun.cpp index 09ce3a1..b15c1e2 100644 --- a/tun.cpp +++ b/tun.cpp @@ -67,7 +67,11 @@ void Tun::setIp(uint32_t ip, uint32_t destIp, bool includeSubnet) string ips = Utility::formatIp(ip); string destIps = Utility::formatIp(destIp); +#ifdef LINUX + snprintf(cmdline, sizeof(cmdline), "/sbin/ifconfig %s %s netmask 255.255.255.0", device, ips.c_str()); +#else snprintf(cmdline, sizeof(cmdline), "/sbin/ifconfig %s %s %s netmask 255.255.255.255", device, ips.c_str(), destIps.c_str()); +#endif if (system(cmdline) != 0) syslog(LOG_ERR, "could not set tun device ip address");