Merge pull request #3422 from Sonicadvance1/Linux_bba_bridge

Support multiple bridge interfaces in Linux.
This commit is contained in:
Ryan Houdek 2016-01-01 04:23:06 -05:00
commit f836e5937f
1 changed files with 19 additions and 8 deletions

View File

@ -45,16 +45,27 @@ bool CEXIETHERNET::Activate()
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE;
strncpy(ifr.ifr_name, "Dolphin", IFNAMSIZ);
const int MAX_INTERFACES = 32;
for (int i = 0; i < MAX_INTERFACES; ++i)
{
strncpy(ifr.ifr_name, StringFromFormat("Dolphin%d", i).c_str(), IFNAMSIZ);
int err;
if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0)
{
if (i == (MAX_INTERFACES - 1))
{
close(fd);
fd = -1;
ERROR_LOG(SP1, "TUNSETIFF failed: err=%d", err);
ERROR_LOG(SP1, "TUNSETIFF failed: Interface=%s err=%d", ifr.ifr_name, err);
return false;
}
}
else
{
break;
}
}
ioctl(fd, TUNSETNOCSUM, 1);
readEnabled.store(false);