|
@@ -106,6 +106,9 @@ BSDEthernetTap::BSDEthernetTap(
|
|
|
if (std::find(devFiles.begin(),devFiles.end(),std::string(tmpdevname)) == devFiles.end()) {
|
|
|
long cpid = (long)vfork();
|
|
|
if (cpid == 0) {
|
|
|
+#ifdef ZT_TRACE
|
|
|
+ fprintf(stderr, "DEBUG: ifconfig %s create" ZT_EOL_S, tmpdevname);
|
|
|
+#endif
|
|
|
::execl("/sbin/ifconfig","/sbin/ifconfig",tmpdevname,"create",(const char *)0);
|
|
|
::_exit(-1);
|
|
|
} else if (cpid > 0) {
|
|
@@ -117,6 +120,9 @@ BSDEthernetTap::BSDEthernetTap(
|
|
|
if (!stat(devpath,&stattmp)) {
|
|
|
cpid = (long)vfork();
|
|
|
if (cpid == 0) {
|
|
|
+#ifdef ZT_TRACE
|
|
|
+ fprintf(stderr, "DEBUG: ifconfig %s name %s" ZT_EOL_S, tmpdevname, _dev.c_str());
|
|
|
+#endif
|
|
|
::execl("/sbin/ifconfig","/sbin/ifconfig",tmpdevname,"name",_dev.c_str(),(const char *)0);
|
|
|
::_exit(-1);
|
|
|
} else if (cpid > 0) {
|
|
@@ -163,6 +169,9 @@ BSDEthernetTap::BSDEthernetTap(
|
|
|
OSUtils::ztsnprintf(metstr,sizeof(metstr),"%u",_metric);
|
|
|
long cpid = (long)vfork();
|
|
|
if (cpid == 0) {
|
|
|
+#ifdef ZT_TRACE
|
|
|
+ fprintf(stderr, "DEBUG: ifconfig %s lladdr %s mtu %s metric %s up" ZT_EOL_S, _dev.c_str(), ethaddr, mtustr, metstr);
|
|
|
+#endif
|
|
|
::execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"lladdr",ethaddr,"mtu",mtustr,"metric",metstr,"up",(const char *)0);
|
|
|
::_exit(-1);
|
|
|
} else if (cpid > 0) {
|
|
@@ -192,6 +201,9 @@ BSDEthernetTap::~BSDEthernetTap()
|
|
|
|
|
|
long cpid = (long)vfork();
|
|
|
if (cpid == 0) {
|
|
|
+#ifdef ZT_TRACE
|
|
|
+ fprintf(stderr, "DEBUG: ifconfig %s destroy" ZT_EOL_S, _dev.c_str());
|
|
|
+#endif
|
|
|
::execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"destroy",(const char *)0);
|
|
|
::_exit(-1);
|
|
|
} else if (cpid > 0) {
|
|
@@ -215,6 +227,9 @@ static bool ___removeIp(const std::string &_dev,const InetAddress &ip)
|
|
|
long cpid = (long)vfork();
|
|
|
if (cpid == 0) {
|
|
|
char ipbuf[64];
|
|
|
+#ifdef ZT_TRACE
|
|
|
+ fprintf(stderr, "DEBUG: ifconfig %s inet %s -alias" ZT_EOL_S, _dev.c_str(), ip.toIpString(ipbuf));
|
|
|
+#endif
|
|
|
execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"inet",ip.toIpString(ipbuf),"-alias",(const char *)0);
|
|
|
_exit(-1);
|
|
|
} else if (cpid > 0) {
|
|
@@ -245,6 +260,9 @@ bool BSDEthernetTap::addIp(const InetAddress &ip)
|
|
|
long cpid = (long)vfork();
|
|
|
if (cpid == 0) {
|
|
|
char tmp[128];
|
|
|
+#ifdef ZT_TRACE
|
|
|
+ fprintf(stderr, "DEBUG: ifconfig %s %s %s alias" ZT_EOL_S, _dev.c_str(), ip.isV4() ? "inet" : "inet6", ip.toString(tmp));
|
|
|
+#endif
|
|
|
::execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),ip.isV4() ? "inet" : "inet6",ip.toString(tmp),"alias",(const char *)0);
|
|
|
::_exit(-1);
|
|
|
} else if (cpid > 0) {
|
|
@@ -375,6 +393,9 @@ void BSDEthernetTap::setMtu(unsigned int mtu)
|
|
|
if (cpid == 0) {
|
|
|
char tmp[64];
|
|
|
OSUtils::ztsnprintf(tmp,sizeof(tmp),"%u",mtu);
|
|
|
+#ifdef ZT_TRACE
|
|
|
+ fprintf(stderr, "DEBUG: ifconfig %s mtu %s" ZT_EOL_S, _dev.c_str(), tmp);
|
|
|
+#endif
|
|
|
execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"mtu",tmp,(const char *)0);
|
|
|
_exit(-1);
|
|
|
} else if (cpid > 0) {
|