Support multiple bridge interfaces in Linux.

This allows you to run multiple instances of Dolphin that touch the BBA (Up to a 32 interface limit)
This commit is contained in:
Ryan Houdek
2016-01-01 02:51:31 -06:00
parent 787bf156f0
commit 4e22bab71d

View File

@ -45,16 +45,27 @@ bool CEXIETHERNET::Activate()
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE; 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; int err;
if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0) if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0)
{
if (i == (MAX_INTERFACES - 1))
{ {
close(fd); close(fd);
fd = -1; 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; return false;
} }
}
else
{
break;
}
}
ioctl(fd, TUNSETNOCSUM, 1); ioctl(fd, TUNSETNOCSUM, 1);
readEnabled.store(false); readEnabled.store(false);