mirror of
https://github.com/norohind/hans.git
synced 2025-04-13 13:17:23 +03:00
Use iproute2 instead of net-tools
This commit is contained in:
parent
7659a5e173
commit
266a5f7d7a
10
src/tun.cpp
10
src/tun.cpp
@ -54,6 +54,8 @@ static void winsystem(char *cmd)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ip_path "/sbin/ip "
|
||||||
|
|
||||||
Tun::Tun(const string *device, int mtu)
|
Tun::Tun(const string *device, int mtu)
|
||||||
{
|
{
|
||||||
this->mtu = mtu;
|
this->mtu = mtu;
|
||||||
@ -77,7 +79,9 @@ Tun::Tun(const string *device, int mtu)
|
|||||||
<< "\" mtu=" << mtu;
|
<< "\" mtu=" << mtu;
|
||||||
winsystem(cmdline.str().data());
|
winsystem(cmdline.str().data());
|
||||||
#else
|
#else
|
||||||
cmdline << "/sbin/ifconfig " << this->device << " mtu " << mtu;
|
// ip link set dev <device> mtu <mtu>
|
||||||
|
cmdline << ip_path << "link set dev " << this->device << " mtu " << mtu;
|
||||||
|
// cmdline << "/sbin/ifconfig " << this->device << " mtu " << mtu;
|
||||||
if (system(cmdline.str().data()) != 0)
|
if (system(cmdline.str().data()) != 0)
|
||||||
syslog(LOG_ERR, "could not set tun device mtu");
|
syslog(LOG_ERR, "could not set tun device mtu");
|
||||||
#endif
|
#endif
|
||||||
@ -102,7 +106,9 @@ void Tun::setIp(uint32_t ip, uint32_t destIp)
|
|||||||
if (!tun_set_ip(fd, ip, ip & 0xffffff00, 0xffffff00))
|
if (!tun_set_ip(fd, ip, ip & 0xffffff00, 0xffffff00))
|
||||||
syslog(LOG_ERR, "could not set tun device driver ip address: %s", tun_last_error());
|
syslog(LOG_ERR, "could not set tun device driver ip address: %s", tun_last_error());
|
||||||
#elif LINUX
|
#elif LINUX
|
||||||
cmdline << "/sbin/ifconfig " << device << " " << ips << " netmask 255.255.255.0";
|
// ip addr add <ip>/24 dev <device>
|
||||||
|
cmdline << ip_path << "addr add " << ips << "/24 dev " << device;
|
||||||
|
// cmdline << "/sbin/ifconfig " << device << " " << ips << " netmask 255.255.255.0";
|
||||||
if (system(cmdline.str().data()) != 0)
|
if (system(cmdline.str().data()) != 0)
|
||||||
syslog(LOG_ERR, "could not set tun device ip address");
|
syslog(LOG_ERR, "could not set tun device ip address");
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user