{
if (!mmac[0] && !mmac[1] && !mmac[2] && !mmac[3] && !mmac[4] && !mmac[5])
{
SendArpReq(1, myip, mmac);
return ;
}
sthread = CreateThread(NULL, 0, CheckHost, 0, 0, 0);
SetTimer(1, 7 *(toip - fromip), NULL); //启动定时器
}
if (WaitForSingleObject(sthread, 0) != WAIT_OBJECT_0)
{
return ;
}
//test using self host
/* hostList[currentHstIndex].sniffer = 1;
hostList[currentHstIndex].ipConflict = 0;
hostList[currentHstIndex].arpCheat = 0;
hostList[currentHstIndex].ip = htonl(myip);
hostList[currentHstIndex].ipConflict = 1;
hostList[currentHstIndex].arpCheat = 1;
memcpy(hostList[currentHstIndex].mac,mmac,6);
currentHstIndex++;
*/
int i, j;
for (i = 0; i < currentHstIndex; i++)
{
for (j = 0; j < oldHstIndex; j++)
{
if (oldHostList[j].ip == hostList[i].ip)
{
hostList[i].sniffer = oldHostList[j].sniffer;
hostList[i].ipConflict = oldHostList[j].ipConflict;
hostList[i].arpCheat = oldHostList[j].arpCheat;
break;
}
}
}
SetTimer(1, 20000, NULL);
for (i = m_hostList.nVWndPos / 13, j = 0; i < currentHstIndex; i++, j++)
{
CString str;
m_hostList.SetText(j + 1, 0, inet_ntoa(*(struct in_addr*)(&(hostList[i].ip))
));
if (hostList[i].sniffer == 0)
m_hostList.SetText(j + 1, 2, "OFF");
else
m_hostList.SetText(j + 1, 2, "ON");
str.Format("%02x-%02x-%02x-%02x-%02x-%02x", hostList[i].mac[0],
hostList[i].mac[1], hostList[i].mac[2], hostList[i].mac[3],
hostList[i].mac[4], hostList[i].mac[5]);
m_hostList.SetText(i + 1, 1, str);
if (hostList[i].arpCheat == 0)
m_hostList.SetText(j + 1, 3, "OFF");
else
m_hostList.SetText(j + 1, 3, "ON");
if (hostList[i].ipConflict == 0)
m_hostList.SetText(j + 1, 4, "OFF");
else
m_hostList.SetText(j + 1, 4, "ON");
}
for (; j < 31; j++)
{
for (int k = 0; k < 5; k++)
m_hostList.SetText(j + 1, k, "");
}
m_hostList.Invalidate();
unsigned char mac[6];
memcpy(mac, mmac, 4);