How to make TAP adapter accept all traffic form PC?

0

I'm developing a client application to capture traffic on a PC. I'm using OpenVpn tun/tap adapter. But it dosen't work, when I'm testing application traffic goes through Wireless LAN adapter. How to make all traffic go through tun/tap adapter?

DWORD active = 1;
DWORD len;
int status = DeviceIoControl(handle, 
    TAP_CONTROL_CODE(6, 0), // TAP_IOCTL_SET_MEDIA_STATUS
    &active,
    sizeof(active),
    &active,
    sizeof(active),
    &len,
    NULL
    );
if(status == 0)
{
    return NULL;
}

int configtun[3] = {0x01000b0a, 0x01000b0a, 0x0000ffff}; // IP, NETWORK, MASK
configtun[0] = inet_addr(ip);
configtun[1] = inet_addr(ip);
char *p = (char*)(configtun+1);
*(p+3) = 0;

status = DeviceIoControl(handle,
TAP_CONTROL_CODE(10, 0), // TAP_IOCTL_CONFIG_TUN
    &configtun,
    sizeof(configtun),
    &configtun,
    sizeof(configtun),//active),
    &len,
    NULL
    );
if(status == 0)
{
    return NULL;
}
networking
openvpn

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0